Sunday, 17 June 2012

Write a shell script to count number of spaces in a file.


count=0
       space
       for i in `cat a.sh`
       do
       if [ $i != " " ]
       then
       count=`expr $count + 1`
       else
       space=`expr $space + 1`
       fi
       done
       echo $space

No comments:

Post a Comment