Day 11 - Basic Linux Shell Scripting

Day 11 - Basic Linux Shell Scripting

Shell scripting -> A shell script is a list of commands in a computer program that is run by the Unix shell which is a command line interpreter. A shell script usually has comments that describe the steps. The different operations performed by shell scripts are program execution, file manipulation and text printing.

This saves you time because you don't have to write certain commands again and again. You can perform daily tasks efficiently and even schedule them for automatic execution.

There are several shells are available for Linux systems like –

  • BASH (Bourne Again SHell) – It is most widely used shell in Linux systems. It is used as default login shell in Linux systems and in macOS. It can also be installed on Windows OS.

  • CSH (C SHell) – The C shell’s syntax and usage are very similar to the C programming language.

  • KSH (Korn SHell) – The Korn Shell also was the base for the POSIX Shell standard specifications etc.

What is #!/bin/bash?

#!/bin/bash is the first line of the script and is called Shebang. Shebang tells the shell to execute it via bash shell. Shebang is simply an absolute path to the bash interpreter.

File colour:

Executable scripts appear in a different color from rest of the files and folders. scripts with execution rights appear as green.

Task :

Write first shell scripting using Bash Shell

Let's create a simple script in bash that outputs Hello DevOps community.

Provide execution rights to your user:

Modify the file permissions and allow execution of the script by using the command below:

Run the script:

run the script in the following ways:

./hello.sh

bash hello.sh.

Here's the output:


Thanks for reading to the end; I hope you gained some knowledge.❤️🙌

PARAMVEER SINGH