Shell Script Basics
Shell scripting is an important part of process automation in Linux. Scripting helps you write a sequence of commands in a file and then execute them.
Type of Shell:
- Bourne Shell
- C Shell
- Korn Shell
- Bourne-Again Shell (BASH)
How to create shall script file?
Your script file name is File_name.sh
How to execute a shell script file?
- sh filename.sh
- ./filename.sh
- . filename.sh
Shell Script Methods:
Dynamic:
Example:
echo "enter two values:"
read a
read b
c=expr $a + $b
echo "Result is: $c"
Static:
Example:
a=360
b=420
c=expr $a + $b
echo "Result is: $c"
Argument Parsing:
Example:
c=expr $1 + $2
echo "Result is: $c"
echo "Total number of values: $#"
echo "Show values: $*"
echo "show file Name: $0"
Comments
Post a Comment