UNIX Shell Script
UNIX Shell Script
• The reason for the persistent Assembly code was not the
inability of C but the inability of machines and compilers
of that time; compilers were bad at optimization and
even a mini-second gained by using Assembly meant a
thing.
Why use Linux?
• Linux may be a perfect operating system if you want to
get rid of viruses, malware, slowdowns, crashes, costly
repairs, and many more.
• Each flavor of shell has its own set of recognized commands and
functions.
Using Shell Variables
• Variable Names
• The name of a variable can contain only letters (a to z or A
to Z), numbers ( 0 to 9) or the underscore character ( _).
• By convention, Unix shell variables will have their names in
UPPERCASE
• NAME="Zara Ali"
• echo $NAME
$./test.sh
First Index: Zara
Second Index: Qadir
#!/bin/sh
NAME[0]="Zara"
NAME[1]="Qadir"
NAME[2]="Mahnaz"
NAME[3]="Ayan"
NAME[4]="Daisy"
echo "First Method: ${NAME[*]}"
echo "Second Method: ${NAME[@]}"
$./test.sh
First Method: Zara Qadir Mahnaz Ayan Daisy
Second Method: Zara Qadir Mahnaz
Shell Basic Operators
• There are various operators supported by each shell.
• Basic operators
• Arithmetic Operators
• Relational Operators
• Boolean Operators
• String Operators
• File Test Operators
#!/bin/sh
val=`expr 2 + 2`
echo "Total value : $val"
Total value : 4