1.What is Shell Scripting?
Shell Scripting is a program to write a series of commands.
Shell scripting is an important part of process automation in Linux and you use it to automate your tasks.
You write a sequence of commands in a file and then execute them. This saves you time as you can keep the regularly used commands of a task in that file and execute those at once with a single command. Thus, you perform daily tasks efficiently and this also enables you to schedule your task for automatic execution using crontab.
2.What is #!/bin/bash? Can we write #!/bin/sh as well?
Any shell script is identified by Shebang.
Shebang is a combination of bash (#) and bang (!), followed by the shell path. The shebang ( #!) at the head of a script tells your system that this file is a set of commands to be fed to the command interpreter.
The #! is a two-byte magic number, a special marker that designates a file type, for our case, an executable shell script.
The command interpreter executes the commands in the script, starting at the top (the line following the Shebang line), and ignoring comments.
Yes, we can write #!/bin/sh as well, this is the original version of shell. There are different types of shell scripts. I have mentioned below some commonly used ones:
#!/bin/sh - Bourne Shell - the original one
#!/bin/ksh - Korn Shell
#!/bin/bash - the Bourne again Shell - the most used one
3.Write a Shell Script which prints I will complete #90DaysOfDevOps challenge.
Script:
Execution:
4.Write a Shell Script to take a user input, input from arguments and print the variables.
Script:
Execution:
5.Write a Shell Script comparing 2 numbers.
Script:
Execution:
If this post was helpful, please follow and click the ๐ button below to show your support.
_ Thank you for reading!
_Sudipa