Script No .
Definition:
Write a shell script to execute following commands
o Sort file abc.txt and save this sorted file inxyz.txt
o Give an example of: To execute commands together without affecting result of eachother.
o How to print “thisis a three –line 1. Textmessage”
o Which command display version of theUNIX?
o How would you get online help of catcommand?
Script:
clear
ch=0
while [ $ch -ne 6 ]
do
echo " M E N U "
echo "1: Sort a file and store the sorted file in new file"
echo "2: Execute more than one command without affecting results"
echo "3: Display version of Linux"
echo "4: Get online help of a command"
echo "5: Print multiline message"
echo "6: Exit"
echo "Enter your choice"
read ch
clear
case $ch in
1) echo Enter the name of file to be sorted
read fn
echo Enter the name the file to store the sorted file of $fn
read fn2
sort $fn >$fn2
cat $fn2;;
2) date; ls; echo "Hellow";;
3) echo Vesion of Linux
uname -nr;;
4) echo "enter the name of commanand for help"
read cmnd
man $cmnd;;
5) echo thisis
echo a three -line
echo message;;
6) exit;;
*) echo "Invalid choice"
exit;;
esac
done
OR
echo "1. Sort file abc.txt and save thi sortedd file in xyz.txt"
echo "2. Execute multiple commands without affecting other"
echo "3. Print Three line message "
echo "4. Display version of Unix"
echo "5. Help of cat command"
echo -n "enter your choice"
read ch
case $ch in
1) sort abc.txt>xyz.txt;;
2) date;cal;;
3) echo -e "This is a \n Three line \n Message";;
4) uname -r;;
5) man cat;;
esac