Table of contents
- <mark>What is Kernel</mark>
- <mark>What is Shell</mark>
- <mark>What is Linux Shell Scripting?</mark>
- <mark>What is </mark> #!/bin/bash? <mark>can we write </mark> #!/bin/sh <mark>as well?</mark>
- <mark>Write an Example of If else in Shell Scripting by comparing 2 numbers?</mark>
- <mark>Write a Shell Script to take user input, input from arguments and print the variables.</mark>
What is Kernel
The kernel is a computer program that is the core of a computer’s operating system, with complete control over everything in the system.
What is Shell
A shell is special user program which provide an interface to user to use operating system services. Shell accept human-readable commands from user and convert them into something which kernel can understand. It is a command language interpreter that execute commands read from input devices such as keyboards or from files. The shell gets started when the user logs in or start the terminal.
What is Linux Shell Scripting?
A shell script is a computer program designed to be run by a linux shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.
What is #!/bin/bash?
can we write #!/bin/sh
as well?
#!/bin/bash
is called a "shebang" or "hashbang". It is a special instruction that tells the Unix/Linux shell which interpreter to use to execute the script. In this case, #!/bin/bash
indicates that the script should be run using the Bash shell.
Yes, you can also use #!/bin/sh
in your script. However, this would instruct the shell to use the default shell interpreter, which may be different from Bash. sh
is the original Unix shell and is generally available on all Unix/Linux systems.
The difference between #!/bin/bash
and #!/bin/sh
is that bash
is an enhanced version of sh
with additional features and functionality, such as better support for scripting, enhanced history, and more advanced command-line editing capabilities. However, sh
is a more lightweight shell and may be more suitable for simple scripts that do not require advanced features.
Write an Example of If else in Shell Scripting by comparing 2 numbers?
#!/bin/bash echo "enter the first number" read num1 echo "enter the second number" read num2 if [ $num1 -gt $num2 ]; then echo "$num1 is greater than $num2" elif [ $num1 -lt $num2 ]; then echo "$num1 is less than $num2" else echo "$num1 is equal to $num2" fi :wq!
Write a Shell Script to take user input, input from arguments and print the variables.
#!/bin/bash
echo "what is your name"
read name
echo "your name is $name"
:wq!
Write a Shell Script which prints
I will complete #90DaysOofDevOps challenge ?
abhi@ubandupc:~/Day4$ vim print.sh
#!/bin/bash
echo "I will complete #90DaysOofDevOps challenge"
:wq!
for check
sh print.sh