Lab 8: Program to count the number of lines, words and characters in the given file
echo "enter the existing file"
read filename
if [ -f $filename ]
then
echo "Total line in $filename"
wc -l $filename | cut -c 1-2
echo "Total character in $filename"
wc -c $filename | cut -c 1-2
echo "Total Words in $filename"
wc -w $filename | cut -c 1-2
else
echo "File Doesnot exit"
fi
read filename
if [ -f $filename ]
then
echo "Total line in $filename"
wc -l $filename | cut -c 1-2
echo "Total character in $filename"
wc -c $filename | cut -c 1-2
echo "Total Words in $filename"
wc -w $filename | cut -c 1-2
else
echo "File Doesnot exit"
fi
Leave a Comment