#Day4 #90DaysOfDevOps
Index
Solution of tasks
My Learnings
- Explain in your own words and examples, what is Shell Scripting for DevOps.
Shell scripting is like having linux commands all together in one file and once you execute all the commands will be also executed. its like automating your linux machine.
example :
you want to create a directory, and there you want to create one file , want to add fruits name in this file, want to print content of fruits file.
now if you create one shell script file which has all this commands written.
sample shell script which will perform above tasks
#--------------starting shell script file------------------------
mkdir demo
cd demo
cat << EOF > fruits.txt
Mango
Watermelon
Kiwi
Apple
EOF
cat fruits.txt
#---------------End of shell script file---------------------------
- What is `#!/bin/bash?` can we write `#!/bin/sh` as well?
The line #!/bin/bash is called a "shebang" (also known as a hashbang), and it is used to specify the interpreter that should be used to execute the script. In this case, #!/bin/bash indicates that the script should be interpreted and executed using the Bash shell.
Yes, we can also use #!/bin/sh as the shebang to indicate that the script should be executed using the system's default shell (commonly, this points to the Bourne shell or a compatible shell). This is a more generic approach since /bin/sh typically points to the default shell on Unix-like systems, which could be Bash, Dash, Ash, or another compatible shell.
- 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
My Learnings
Today I learned about how to use 'Read' keyword to take input from user in Shell script
I also learned how to use if else conditions in shell scripting
I also learned how to do addition,multiplication with input values (Note: normally we get input values in shell scripting in String manner only)