Program to count no of line, words and charecters of a input file |Shell program|

#!/bin/bash
echo Enter the file name
read file
w=`cat $file | wc -w`
c=`cat $file | wc -c`
l=`grep -c "." $file`
echo Number of characters in $file is $(( $c - 1 ))
echo Number of words in $file is $w
echo Number of lines in $file is $l
  
OUTPUT 

This is the file 'sample'


Enter the file name
sample
Number of characters in sample is 15
Number of words in sample is 4
Number of lines in sample is 2

Post a Comment

0 Comments