Monday, January 20, 2014

Unix and Shell Programming - illustrate WC Commands

with 0 Comment
while true
do
echo "MENU"
echo "---------"
echo "1.Number of users"
echo
echo "2.Number of lines words and chracters"
echo
echo 3.Exit
echo
echo Enter your choice
read c
case $c in

1)
echo "Number of users"
echo "--------------------"
echo
who|wc -l
echo
echo
;;

2)
echo "Number of lines words and characters in a File"
echo "--------------------------------------------------------"
echo
ls
echo "Enter the file name"
read f1
if test -f $f1
then
echo
echo "Content of the File"
echo "----------------------"
cat $f1
echo
echo "Number of lines"
wc -l<$f1
echo
echo "Number of Words"
wc -w<$f1
echo
echo "Number of Characters"
wc -c<$f1
echo
else
echo File not Exists.
fi
;;


3)
echo Exit
echo ---
exit
esac
done

-------------
OUTPUT:
-------------
MENU
--------
1.Number of users
2.Number of lines words and characters
3.Exit

Enter your Choice
1
Number of users
--------------------
33


Enter your choice
2

Number of lines words and charcters in a File
-------------------------------------------------------
1   count1.sh   f   indu    priya3   selvi   trans.sh
a   count.sh     f1  Indu   ram     semi.sh  tr.sh
a2   d2        f3    mano    re   sort1 .sh   vidhya

Enter your file name
cmp

Content of the File
----------------------
madurai
thrichy
chennai
delhi
banglore

Number of lines
5
Number of Words
5
Number of Characters
39
---------------------------
Enter your choice
3
Exit

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive