Hello,
i am developing a simple shell script for simulation of wc command but it's not working.Please tell me what is the problem. I have commented the problematic line
if [ $# -lt 1 ]
then
echo "<Improper Usage>"
echo "wcassg <options> file"
else
eval file=\$$#
if [ -f $file ]
then
chars=0
words=0
lines=0
if [ $# -eq 1 ]
then
exec<$file
while read sentence
do
#the line below this is not working i dont know i am not able to use string functions on $sentence
chars=`expr $chars + \`expr length $sentence\``
set $sentence
lines=`expr $lines + 1`
words=`expr $words + $#`
done
echo "Number Of Lines :$lines"
echo "Number Of Words :$words"
echo "Number Of Characters :$chars"
fi
else
echo "$file does not exists"
fi
fi