Script No .
Definition:
Write a shell script to display the following menu for a particular file :
i. Display all the words of a file in ascendingorder.
ii. Display a file in descendingorder.
iii. Toggle all the characters in thefile.
iv. Display type of the file.
Script:
clear
echo M E N U
echo 1: Display all the words in ascending order
echo 2: Display all words in descending order
echo 3: Toggle all chacters of the file
echo 4: Check the type of file
echo 5: Exit
echo Enter your choice
read ch
case $ch in
1) echo Enter the name of the file
read fname
for i in $(caat $fname)
do
echo $i >> temp
done
sort -r temp
rm temp;;
2) ;;
3) echo Enter the text
read text
echo $text | tr '[a-z [A-Z]' '[A-Z] [a-z]';;
4);;
5) exit;;
*) echo invalid choice;;
esac
OR
echo "1. Display all the words of a file in ascending oreder."
echo "2. Display a file in descending order."
echo "3. Toggle all the characters in the file."
echo "4. Display type of the file."
echo "Enter your choice "
read ch
echo "Enter the filename"
read fn
case $ch in
1) sort $fn;;
2) sort -r $fn;;
3) cat $fn | tr "[a-z][A-Z]" "[A-Z][a-z]";;
4) file $fn;;
*) echo "Invalide choice"
OR
echo "1. Display all the words of a file in ascending order."
echo "2. Display a file in descending order."
echo "3. Toggle all the characters in the file."
echo "4. Enter your choice"
read ch
echo "Enter your choice"
read ch
echo "Enter the filename"
read ch
case $ch in
1) sort $fn;;
2) sort -r $fn;;
3) cat $fn | tr "[a-z][A-Z]" "[A-Z][a-z]";;
4) file $fn;;
*) echo "Invalid choice"
esac