loader image

Shell script to count no of lines, words and characters of an input file

Aim: Write a shell script to count the number of lines, words and characters of an input file

#!/bin/bash
echo Enter the filename
read file
c=`cat $file | wc -c`
w=`cat $file | wc -w`
l=`grep -c "." $file`
echo Number of characters in $file is $c
echo Number of words in $file is $w
echo Number of lines in $file is $l
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Scroll to Top