postheadericon Write a script which reads a text file and output key attribute of file


Write a script which reads a text file and output the following 
1). Count of character, words and lines.
2). File in reverse.
3). Frequency of particular word in the file.
4). Lower case letter in place of upper case letter.

File Name : ex15.sh


echo "Enter File Name \c"
read fname
choice=y
while [ "$choice" = "y" ]
do
echo " ------------------------------------"
echo " 1. Count character,words and lines"
echo " 2. Reverse File"
echo " 3. Found frequency of word"
echo " 4. Convert upper to lower"
echo " 5. Convert lower to upper"
echo " 6. Exit
echo " ------------------------------------"
echo "Enter Choice: \c"
read ch
case $ch in
1)
        echo "Total Characters:\c"
        wc -c $fname
        echo "Total Words:\c"
        wc -w $fname
        echo "Total Lines:\c"
        wc -l $fname
        ;;
2)
        rev $fname
        ;;
3)
        echo "Find your word :\c"
       read w
        echo "Frequency:\c"
        grep  -c "$w" $fname
        ;;
4)
        echo "Enter Text : \c"
        read text
        echo $text | tr "[A-Z]" "[a-z]"
        ;;
5)
        echo "Enter Text : \c"
        read text
        echo $text | tr "[a-z]" "[A-Z]"
        ;;

6)         exit
            ;;

*)         echo "Invalid Choice ....."
                        ;;
            esac
 echo "Do u want to continue.....? [y/n]"
 read choice
 case $choice in
  Y|y) choice=y;;
  N|n) choice=n;;
  *) choice=y;;
 esac
done

0 comments:

Follow by Email

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.