The Startup
Published in

The Startup

Shell Script

A shell provides us with an interface to the Unix system. It gathers input and executes based on the input and provides output. Shell is an environment in which we can run our commands, programs, and shell scripts

Shells could be one of the following :

  • The Bourne Shell

A shell script is a computer program designed to be run by the Unix/Linux shell.

A Bash script is a plain text file which contains a series of commands

Creating Script File and Steps to run

  • Create empty file and save the file with .sh extension to make the file as script file.
Variable declaration and printing variable value

IF Condition, while, for loop and switch case: (we can use single or double brace for condition)

Function in shell scripts

There are 4 type of functions.

  1. function with parameter

Calling a function from different files

Exit Statements in shell script

  1. If function executes successfully it returns 0 : exit status is 0

Break and Continue Condition

  • break: which breaks the execution of loop
break nth: example — break 2 : it breaks nested loops upto level 2
  • Continue: If condition is success, which breaks the execution of loop and continues the next execution
continue nth: example — continue 2 : it breaks nested loops upto level 2 and continues the execution


  • To get more detail please check my GitHub account for more details on syntax and live examples.


I hope you find this blog helpful. If you enjoyed it, feel free to hit the clap button below 👏 to help others find it! and follow me on Medium. Thanks for reading. ❤❤❤❤



Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +768K followers.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store