Shell is a program which runs inside Terminal. Whenever user enters any command into Terminal, then its executed by Shell Program. For example – When you enter Command ls -1 ~/Documents inside Terminal then shell program will take it as an input, interpret it and execute it, then print out output on Terminal window. There can be different types of Shell like Bourne Shell, Korn Shell, C Shell.
Most known of these is Bourne Shell, which is commonly known as bash.
What does Shell inside Terminal actually do?
- Displays a prompt message in Terminal Window and then waits for user to enter commands
- Shell reads user-entered command and interprets special symbols in it
- If command typed in Terminal needs to run some program, then shell will located it and then run it
- If command typed by user results in some output, then shell will take that output from MacOS Operating System and will print it on Terminal Window.
How does Shell works?
Essentially Shell is an Interpreter, which takes in commands from user via terminal window and then interpret and execute those commands. For example – If a user types Command ls -1 ~/Documents | wc -1 then Shell well interpreter ls -1 ~/Documents and wc -1 separately. Then due to | in between these two commands, Shell will pass outout of ls -1 ~/Documents to wc -1. Putting together this whole command will print out lines of text in files which are in Documents Directory.
Where is Shell Program files located in Mac?
Usually in Mac OS, program files of Shell are located in /bin directory – this directory can be accessed from Mac Terminal using cd /bin command.
Features of Shell
- Wildcards for matching filenames
- Storing Command History for recalling previous commands quickly
- Pipes for making output of one command, input for other command
- Variables for storing values
How to terminate a Shell?
Just in terminal enter command exit this will send signal to Operating System to stop executing shell and will exit after saving session, copying shared history, saving history.