Tuesday, August 23, 2016

What is a Unix shell?

Shell is a process or a program running on Unix system which provides traditional command line interface, which interprets user commands into operating systems instructions. 

Shell reads the command from the User interface and validates the correctness of the command. All the commands which pass validation, will be sent or redirected to Kernel as a system instructions to perform the respective operation output is sent back to the shell interface. 

How Shell Interprets the commands: 

Shell interpretation is not as simple as we see. A lot of background process happens when ever user press “RETURN” on the user prompt. Shell breaks the commands into individual pieces. Looks for the meaning of those pieces and performs the necessary action. 

Below is the simple explanation of how shell interprets command. 


    sort -d playerslist > playerslist.sorted
This means, "Sort lines in the file playerslist in dictionary order, and put the result in the file playerslist.sorted ." Here's what the shell does with this command:

1.     Breaks up the line into the pieces sort , -d , playerslist> , and playerslist.sorted . These pieces are called words.

2.     Determines the purpose of the words: sort is a command, -d and playerslist are arguments, and > and playerslist.sorted , taken together, are I/O instructions.

3.     Sets up the I/O according to > playerslist.sorted (output to the file playerslist.sorted ) and some standard, implicit instructions.

4.     Finds the command sort in a file and runs it with the option -d (dictionary order) and the argument playerslist (input filename).




Of course, each of these steps really involves several sub steps, each of which includes a particular instruction to the underlying operating system.

1 comment: