Operating Systems: Lab 03 Shell Scripts Lab Instructor: Zainab Iftikhar
Operating Systems: Lab 03 Shell Scripts Lab Instructor: Zainab Iftikhar
Lab 03
Shell Scripts
Lab Instructor: Zainab Iftikhar
Mathematical Operators
Operator Meaning
string1 = string2 string1 is equal to string2
Test Meaning
-s file Non empty file
-f file Is File exist or normal file and not a directory
-d dir Is Directory exist and not a file
-w file Is writeable file
-r file Is read-only file
-x file Is file is executable
Logical Operators
Operator Meaning
! expression Logical NOT
expression1 -a expression2 Logical AND
expression1 -o expression2 Logical OR
Using Arithmetic Operations
Code:
Output:
Example Uppercase to Lowercase
Conversion & Vice Versa
Code:
Output:
If Condition Example
Code:
Output:
If-else Condition Example
Code:
Output:
If-elif Condition Example
Code:
Output:
If-elif Condition Example
Code:
Output:
Case Statement Example
Code:
Output:
for Loop Example
Code:
Output:
for Loop Example
Code:
Output:
while Loop Example
Code:
Output:
Functions
Used for
Good organization
Create re-usable sequences of commands
Function Example
Code:
Output:
Function Example
Code:
Output:
Function Example
Code:
Output
Thank You!