DevOps90DaysChallenge

Shell Scripting for Beginners – How to Write Bash Scripts in Linux

Hi 👋there,

Now we are on the Day 4 task

Basic Linux Shell Scripting for DevOps Engineers.

Day 4 Task:

  1. Explain in your own words and examples, what is Shell Scripting for DevOps.

  2. What is `#!/bin/bash?` can we write `#!/bin/sh` as well?

  3. Write a Shell Script which prints `I will complete #90DaysOofDevOps challenge`

  4. Write a Shell Script to take user input, input from arguments and print the variables.

  5. Write an Example of If else in Shell Scripting by comparing 2 numbers

    1.)What is Shell Scripting?

Shell scripting is a technique in which a programmer writes a series of commands for the shell to execute.

These commands are typically used for automating tasks, such as setting up a development environment, deploying code, or performing system maintenance.

A shell script can be used to automate the process of provisioning and configuring a new server, installing the necessary software, and setting up security.

Shell scripting is used to automate repetitive tasks and streamline the development and deployment process. This can include tasks such as setting up and configuring development environments, building and testing code, deploying code to various environments, and monitoring and maintaining systems.

The commands in shell scripting are written in a script file and can be executed by the shell, usually Bash, to perform the desired tasks.

2.)What is #!/bin/bash?

The “#!/bin/bash” is called a shebang and it is a special type of comment that is used to specify the interpreter that should be used to execute a script.

When a script is executed, the shell looks at the first line of the script file, and checks for the shebang. If it finds it, the shell uses the interpreter specified after the shebang to execute the script. In this case, the script is executed by /bin/bash, which is a common shell on Linux and Unix systems.

#!/bin/bash is a way to specify that the script should be executed by the Bash shell.

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

3.)Write a Shell Script that prints “I will complete #90DaysofDeVops challenge”

4.)Write a Shell Script to take user input, input from arguments, and print the variables.

5.)Write an Example of If else in Shell Scripting by comparing two numbers.

Please, feel free to drop any questions in the comments below. I would be happy to answer them.

If you find this post helpful😊🙂, please follow and click the heart❤❤ button below to show your support.

_ Thank you for reading

_sandhya kumari