#
#Write a script which reads a text file and output the following
#Count of character, words and lines.
#File in reverse.
#Frequency of particular word in the file.
#Lower case letter in place of upper case letter.
#
clear
echo "Enter name of the text file :"
read filename
if [ ! -f $filename ]
then
echo "Please enter proper file name"
exit
fi
echo "====================== AVAILABLE CHOICES ======================"
echo "1. Count of character, words and lines"
echo "2. File in reverse"
echo "3. Frequency of particular word in the file"
echo "4. Lower case letter in place of upper case letter"
echo "E. Exit"
echo "==============================================================="
echo -n "Enter your choice :"
read choice
case $choice in
1)
echo "Total characters :"$(cat $filename | wc -c)
echo "Total words :"$(cat $filename | wc -w)
echo "Total lines :"$(cat $filename | wc -l)
;;
2)
echo "========= FILE IN REVERSE ORDER ========="
str=$(cat $filename | rev)
echo "$str"
;;
3)
echo -n "Enter word to find frequencey :"
read word
c=$(cat $filename | grep -wci $word)
echo "Frequency of word \"$word\" in the file is "$c
;;
4)
str=$(cat $filename)
content=$(echo "$str" | tr [A-Z] [a-z])
echo "$content" > $filename
echo "Uppercase letters are convered to lowercase in file"
;;
[eE])
exit;
;;
esac