2
▪ various purposes
➢ Executing a shell command
➢ Running multiple commands together
➢ Customizing administrative tasks
➢ Performing task automation etc.
3
Use of terminal or editor
$ bash filename
▪ Cat>filename Or
▪ “vi” editor or “nano” editor $ chmod a+x filename
▪ Use of file extension ➔ “ .sh “ $ ./filename
4
5
6
▪ ‘echo’ command without any option then a newline is added by default
▪ ‘-n’ option is used to print any text without new line
▪ ‘-e’ option is used to remove backslash characters from the output
7
‘#’ symbol is used to add single line comment
8
▪ ‘:’ and “ ’ ” symbols are used to add multiline comment
9
while [ condition ]
do
statement
done
10
for (( operation; condition; operation ))
do
statement
done
11
‘read’ command is used to take input from user
12
if [ condition ];
then
statement
fi
13
14
15
16
case expression in
pattern1)
statement ;;
pattern2)
statement ;;
esac
17
18
19
20
▪ combine string variables in bash by placing variables together or using ‘+’ operator
21
Need to assign start &
end value
22
▪ Use of double brackets
23
24
25
▪ Bash function can pass both numeric and string values
26
27
▪ ‘-d’ option is used to test a particular directory is exist or not
28
▪ Read any file line by line in bash by using loop
29
▪ ‘-i’ option is used to get permission from the user before removing the file
30
▪ ‘>>’ option is used to append text into a file
31
▪ ‘-f’ option is used in the following script to test the file existence
32
▪ Every part of date and time value can be parsed using ‘Y’, ‘m’, ‘d’, ‘H’, ‘M’ and ‘S’