Table of contents
No headings in the article.
Shell Scripting for DevOps
Shell Scripting - It is a command-line interpreter that translates every command run by the user into the language understood by the kernel.
For DevOps - We need a basic understanding of programming language to automate daily tasks hence shell/ash scripting can be used. It can automate all the ad -tasks easily. We can use it for creating a backup, and data syncing. sending emails in bulk.
What is #!/bin/bash?
can we write #!/bin/sh
as well?
We can use but the shells will be different. Here #!/bin/bash?
is used as a command-line interpreter and is also commonly used. Whereas, when #!/bin/sh
is used it instructs the internal system shell to start interpreting the scripts.
#!/bin/bash?
It is known as shebang in UNIX. It uses a bash shell.
#!/bin/sh
It is basically to instruct the operating system that we have to use the Bourne shell.
Sample Shell Scripts
#!/bin/sh
echo "I will complete my #90DaysofDevops challenge"
#!/bin/bash
echo " Who I'm i talking too"
read varname
echo "Nice to meet you" $varname
Output:-
#!/bin/sh
n=10
if [ $((n%2))==0 ]
then
echo "The number is even."
else
echo "The number is odd."
fi