Hi,
I have created one shell script in which it will count number of "~" tilda charactors from each line of the file.But the problem is that i need to count each line count individually, that means. if line one contains 14 "~"s and line two contains 15 "~"s then it should give an error msg.each line having same number of "~"s. so i need to check each line is having same "~" or not . my script gives me output like
**output**
total = 2
linelength= 62
14
linelength= 62
28
my script
#!/bin/bash
DATA_DIR=/export/opt/rtrupld/autosys/scripts_old
data=`ls $DATA_DIR/count.txt`
# count1=1
var=`wc -l < $data`
#var2=`expr $var + 1`
echo "total = $var"
#var3=14
tildacount=0
while read line
do
count=0
linelen=`echo "$line"|wc -c`
echo "linelength= $linelen"
if [ $linelen -gt 0 ]
then
# echo $linelen
until [ $count -ge $linelen ]
do
count=`expr $count + 1 `
char=`echo "$line"|cut -b"$count"`
if [ "$char" = "~" ]
then
tildacount=`expr $tildacount + 1`
fi
done
echo $tildacount
fi
done < $data
#echo $tildacount
----Actually Outpur Required
if line 1 have number of ~=14
line 2 = 14
the correct file else
if line1 =14
line2= 15
then should give an error msg like ~ count is not same as prevoius line.
Thanks & Regards
Ganesh