1) What is shell Scripting for Devops?
Shell scripting is a combination of commands written to automate the Repetitive task. the shell script will be executed in the shell. shell is Command line interpreter and it is a bridge between the kernel and the user. kernel is the heart of OS having two types.
Mono for Linux
micro for windows
Advantages of shell scripting
The command and syntax are exactly the same as those directly entered in command line, so programmer do not need to switch to entirely different syntax
Writing shell scripts are much quicker
Quick start
Interactive debugging etc
2) What is #!/bin/bash?
#!/bin/bash
: It is called as she-bang. It is used to instruct the operating system to use bash as a command interpreter./bin/bash is a more feature-rich shell that includes many additional features and extensions
3) Can we write #!/bin/sh as well?
Yes we can use #!/bin/sh. It is used to execute the file using sh, which is a Bourne shell, or a compatible shell.
4)Write a Shell Script which prints I will complete #90DaysOofDevOps challenge.
5) Write a Shell Script to take user input, input from arguments and print the variables.
#!/bin/bash
echo "enter the name"
read name
echo "enter the surname"
read surname
echo "my name is $name $surname"
6) Write an Example of If else in Shell Scripting by comparing 2 numbers.
#!/bin/bash
num1=80
num2=20
if [ $num1 -gt $num2 ]
then
echo "$num1 is greater than $num2"
else
echo "$num2 is greater than $num1"
fi
thanks for reading,