// Before execution the script please create two directories and and insert file names using cat command //
clear
opt=y
while [ $opt=y ]
do
clear
echo "--Menu Driven program--"
echo
echo
echo "1. USAGE OF TAIL COMMAND"
echo
echo "2. USAGE OF CMP COMMAND"
echo
echo "3. USAGE OF UNIQ COMMAND"
echo
echo "4. USAGE OF RM-R COMMAND"
echo
printf "Enter your choice"
read ch
case $ch in
1) clear
echo "Tail displays line from bottom of the file"
echo
printf "Enter no. of lines to display "
read lin
echo
echo last $lin lines of file str1
echo "--------------------------------"
echo
tail -$lin file1 ;;
2) clear
echo "cmp compare two files and gives the point of difference"
echo "-----------------------------"
echo
echo file1 and file2 are compared
echo
cmp file1 file2 ;;
3) clear
echo
echo "Uniq eliminate adjacent duplicate lines"
echo "--------------------------------"
echo
echo "unique line of jj"
echo
cat file1 | sort | uniq ;;
4) clear
echo
echo "rm -r delete the directory along with contents"
echo "--------------------------------"
echo
echo "Enter subdir name"
read subdir
mkdir $subdir
cd $subdir
touch file1 file2
echo current dir is `pwd`
cd ..
if rm -r $subdir
then
echo $subdir removed successfully
fi ;;
*) clear
echo invalid choice ;;
esac
echo "Continue?"
read opt
done
clear
opt=y
while [ $opt=y ]
do
clear
echo "--Menu Driven program--"
echo
echo
echo "1. USAGE OF TAIL COMMAND"
echo
echo "2. USAGE OF CMP COMMAND"
echo
echo "3. USAGE OF UNIQ COMMAND"
echo
echo "4. USAGE OF RM-R COMMAND"
echo
printf "Enter your choice"
read ch
case $ch in
1) clear
echo "Tail displays line from bottom of the file"
echo
printf "Enter no. of lines to display "
read lin
echo
echo last $lin lines of file str1
echo "--------------------------------"
echo
tail -$lin file1 ;;
2) clear
echo "cmp compare two files and gives the point of difference"
echo "-----------------------------"
echo
echo file1 and file2 are compared
echo
cmp file1 file2 ;;
3) clear
echo
echo "Uniq eliminate adjacent duplicate lines"
echo "--------------------------------"
echo
echo "unique line of jj"
echo
cat file1 | sort | uniq ;;
4) clear
echo
echo "rm -r delete the directory along with contents"
echo "--------------------------------"
echo
echo "Enter subdir name"
read subdir
mkdir $subdir
cd $subdir
touch file1 file2
echo current dir is `pwd`
cd ..
if rm -r $subdir
then
echo $subdir removed successfully
fi ;;
*) clear
echo invalid choice ;;
esac
echo "Continue?"
read opt
done
this is wrong i guess ;)
ReplyDeleteWe are urgently in need of KlDNEY donors for the sum of $500,000.00 USD, Email for more details:
ReplyDeletehospitalcarecenter@gmail.com
WhatsApp +91 779-583-3215