Shell in MacOS

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?

  1. Displays a prompt message in Terminal Window and then waits for user to enter commands
  2. Shell reads user-entered command and interprets special symbols in it
  3. If command typed in Terminal needs to run some program, then shell will located it and then run it
  4. 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.

Location of bash Shell in Mac

Features of Shell

  1. Wildcards for matching filenames
  2. Storing Command History for recalling previous commands quickly
  3. Pipes for making output of one command, input for other command
  4. 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.

Terminating a Shell in Mac

More About Terminal

Gagan

Hi, there I'm founder of ComputerScienceHub(Started this to bring useful Computer Science information just at one place). Personally I've been doing JavaScript, Python development since 2015(Been long) - Worked upon couple of Web Development Projects, Did some Data Science stuff using Python. Nowadays primarily I work as Freelance JavaScript Developer(Web Developer) and on side-by-side managing team of Computer Science specialists at ComputerScienceHub.io

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts