SA Lab List of Experiments-1-1-1
SA Lab List of Experiments-1-1-1
ROUGH RECORD
1. Linux OS File and Directory Organization: Illustrate the structure of Linux Operating
System, file and directory organization.
2. System Management Commands: Demonstrate the management of the system using Linux
commands - date, time, pwd, who, whoami, uptime, users, groups.
3. File & Directory Commands: Demonstrate the use of basic file and directory commands such
as ls, mkdir, rmdir, cd, mv, touch, cp, rm.
4. Input Output Redirection in Linux: Demonstrate the input-output redirections in Linux.
5. Pipes & Filters in Linux: Demonstrate the use of pipes and filters in Linux. (filters - sort,
more, diff, head, tail, grep).
6. Process Management Commands: Demonstrate the use of basic process management
commands such as ps, top, df, kill.
7. Welcome: Read your name from the keyboard and print a welcome message.
8. Sum of two numbers: Read two numbers from keyboard and print its sum.
9. Even or Odd Checking: Check whether a given number is even or odd.
10. Grade of a Student: Read the percentage from the keyboard and print its grade.
(S: percentage >= 90, A: percentage >= 80, B: percentage >= 70,
C: percentage >= 60, D: percentage >= 50, E: percentage >= 40, else F)
11. Print Numbers: Read a number N from the keyboard and print numbers from 0 to N.
12. Number Countdown: Write a shell script that accepts a numerical value N. Then display the
decrementing values of N till it reaches 0.
13. File Merging: Write a shell script which takes three command-line arguments. The first two
are the names of two text files. Their contents are to be merged and copied to a third file
specified by the third argument. Then print the contents of the third file.
14. Greeting the User: Write a shell script that accepts your name and print it with a proper
greeting such as Good Morning, Good Afternoon and Good Evening. (Eg: Good Morning
Hari). Hint: use the ‘date’ command with the proper option. Time 0:00-11:59 may use Good
Morning, 12:00-15:59 may use Good Afternoon and for the remaining time use Good Evening)
15. Sum of Digits of the Process-ID: Write a shell script to print its Process-ID. Then find the
sum of digits of that Process-ID.
16. Simple Calculator: Write a shell script to implement a simple calculator.
17. Sorting and Filtering of Text File Contents: Create a text file having the names of 8 fruits,
one in each line. Write a shell script to sort the list and print the fruit names from line 2 to line
5. Hint: use head and tail commands.
FAIR RECORD
1. Linux OS File and Directory Organization: Illustrate the structure of Linux Operating
System, file and directory organization.
2. System Management Commands: Demonstrate the management of the system using Linux
commands - date, time, pwd, who, whoami, uptime, users, groups.
3. File & Directory Commands: Demonstrate the use of basic file and directory commands such
as ls, mkdir, rmdir, cd, mv, touch, cp, rm.
SHELL SCRIPTS
1. Welcome: Read your name from the keyboard and print a welcome message.
echo "Enter your name"
read NAME
echo "Hai $NAME, welcome"
2. Sum of two numbers: Read two numbers from keyboard and print its sum.
read A
read B
SUM = `expr $A + $B`
echo "Sum of $A and $B is $SUM"
3. Even or Odd Checking: Check whether a given number is even or odd.
echo "Enter the Number: "
read NUM
MOD=`expr $NUM % 2`
if [ $MOD -eq 0 ]
then
echo "The number is Even"
else
echo "The number is Odd"
fi
if [ $P -ge 90 ]
then
echo "Grade is S"
elif [ $P -ge 80 ]
then
echo "Grade is A"
elif [ $P -ge 70 ]
then
echo "Grade is B"
elif [ $P -ge 60 ]
then
echo "Grade is C"
elif [ $P -ge 50 ]
then
echo "Grade is D"
elif [ $P -ge 40 ]
then
echo "Grade is E"
else
echo "Grage is F, Failed"
fi
5. Print Numbers: Read a number N from the keyboard and print numbers from 0 to N.
echo "Enter the number: "
read N
6. Number Countdown: Write a shell script that accepts a numerical value N. Then display the
decrementing values of N till it reaches 0.
echo "Enter the number"
read N
7. File Merging: Write a shell script which takes three command-line arguments. The first two
are the names of two text files. Their contents are to be merged and copied to a third file
specified by the third argument. Then print the contents of the third file.
Let the input files be file1.txt and file2.txt. Their contents be;
file1.txt
hi all…
welcome
file2.txt
have a good day
hope you enjoyed shell scripting
8. Greeting the User: Write a shell script that accepts your name and print it with a proper
greeting such as Good Morning, Good Afternoon and Good Evening. (Eg: Good Morning
Hari). Hint: use the ‘date’ command with the proper option. Time 0:00-11:59 may use Good
Morning, 12:00-15:59 may use Good Afternoon and for the remaining time use Good Evening)
HR=$(date +%H)
if [ $HR -lt 12 ]
then
echo "Hi $NAME, Good Morning"
elif [ $HR -lt 16 ]
then
echo "Hi $NAME, Good Afternoon"
else
SA Lab Rev21 - List of Experiments Page 4 of 6
echo "Hi $NAME, Good Evening"
fi
9. Sum of Digits of the Process-ID: Write a shell script to print its Process-ID. Then find the
sum of digits of that Process-ID.
PID=$$
echo "Process-ID is $PID"
SUM=0
echo "Options"
echo "1 for addition A+B"
echo "2 for subtraction A-B"
echo "3 for multiplication A*B"
echo "4 for integer division A/B"
case "$OP" in
"1") C=`expr $A + $B`
echo "$A + $B = $C"
;;
11. Sorting and Filtering of Text File Contents: Create a text file having the names of 8 fruits,
one in each line. Write a shell script to sort the list and print the fruit names from line 2 to line
5. Hint: use head and tail commands.
Let the file be “fruits.txt” containing the fruit names given below. Give the filename with the
program name as command line argument.
mango
papaya
banana
apple
orange
lemon
guava
jackfruit
Program:
#!/bin/sh
FILE=$(cat $1)