Task:-
Explain in your own words and examples, what is Shell Scripting for DevOps.
What is
#!/bin/bash?
can we write#!/bin/sh
as well?Write a Shell Script that prints
I will complete the #90DaysOofDevOps 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 2 numbers
Answer:-
The shell script is part of the automation process in Linux, where we use a set of Linux commands and execute them to perform specific tasks. A shell script may include comments, where we can describe the steps. It starts with “#!/bin/bash”. Operations, that we may perform with the help of Shell Script are file manipulations, text operations & printing, and many more. Each Shell Scripting file will have a “.sh” extension, e.g. “file1.sh” Example:-
Go to terminal git bash type vim file1.sh#!/bin/bash
echo "Hello world"
echo "My name is Amit Kumar"
save:- press keyboard <esc> then <:wq>
chack file1.sh print:- cat file1.sh, ls-la to check file permission, chmod 777 file1.sh
./file1.sh - this command shows my file content print.
#!/bin/bash is known as shebang. Script files use the shebang line “#!/bin/bash” to set bash.
Yes, we can use #!/bin/sh. “bash” and “sh” are two different shells. Bash is sh, with more features and better syntax.
Script:
#!/bin/bash
echo “90DaysOfDevOps challenge”
Script:
#!/bin/bash
echo "Hello, I am Jarvis! What is your name?"
read var name
echo "Nice to meet you $var name"