Day 4: Basic Linux Shell Scripting for DevOps Engineers

Day 4: Basic Linux Shell Scripting for DevOps Engineers

ยท

2 min read

Table of contents

No heading

No headings in the article.

#Day4 of #90DaysofDevops challenge

Shell Scripting

In the simplest term, a shell script is a file containing a series of commands. The shell reads this file and carries out the commands as they have been entered directly as the command line.

Normally, the shell script has the file extension ".sh".

Shell scripting is used to automate repetitive tasks and streamline the development and deployment process.

What is #!/bin/bash? Can we write #!/bin/sh as well?

The "#!/bin/bash" is called a shebang in Unix. Shebang is a collection of characters or letters that consist of a number sign and exclamation mark, that is (#!) at the beginning of a script. The main function of a shell is to interpret the UNIX commands given by the user.

Unix consists of numerous shells out of that bash is one of them that is widely used. It is the default shell assigned by Linux-based operating systems.

The shebang, #!/bin/bash when used in scripts is used to instruct the operating system to use bash as a command interpreter.

#!/bin/sh: It is used to execute the file using sh, which is a Bourne shell, or a compatible shell.

yes, you can use "#!/bin/sh" instead of "#!/bin/bash" to specify that the script should be executed by the sh shell.

Write a shell script that prints "I will complete #90DaysofDevOps challenge"

Write a shell script to take user input, input from arguments, and print the variables

Write an example of if else in shell scripting by comparing two numbers

Thank you for reading! ๐Ÿ

-Nidhi

ย