Lab 3
Lab 3
to compiled.
► There are different types of shells
are you
bash ch
g
usi n
In d i
Introduction to Shell programming (cont’d)
To execute ./first.sh
Introduction to Shell programming (cont’d)
System variables
Shell programming: Variables & Comments
► User defined variables: maintained by the user
► By convention written by small letters , but there is no strict rules
User variables
Shell programming: Read input from keyboard
Example
Shell programming: Read input from keyboard
► Accept the input the same line with instruction string
► Use –p flag before the variable name
► Example
Example
# Read an array
Shell programming: Read input from keyboard
# Output
Shell programming: Integer comparison
► There are two ways of integer comparison in shell
scripting
i. Using Square bracket []
► -eq : equals to
► -ne : not equal to
► -gt : grater than
► -ge : greater than or equal to
► -lt : less than
► -le : less than or equal to
Shell programming: Integer comparison
If [condition]
then
Syntax Statements
fi
Example
Output
Statements: if then statement
Example
Statements: if then else statement
If [condition]
then
Statements
Syntax else
statements
fi
Example
Out
Statements : if then else statement
Example
Statements: If then else statements
Example