Hi,
I have a little problem with counting lines. I know similar topics from this forum, but they don't resolve my problem. I have file with lines like this:
2009-05-25 16:55:32,143 some text some regular expressions ect.
2009-05-25 16:55:32,144 some text.
2009-05-28 18:15:12,148 some error logs.
2009-05-28 18:15:12,148 some error logs.
2009-05-28 18:15:12,149 some error logs.
2009-05-28 18:15:12,150 some error logs.
2009-06-25 16:55:32,222 some text some regular expressions ect.
2009-06-25 16:55:32,223 some text some regular expressions ect.
So time stamp can be different. I want to count just messages which are the same in the line. I found this on forum:
#!/bin/ksh
cnt=0
while read line
do
# set the variable contents
((cnt+=1))
eval a${cnt}="\$line"
if [[ $cnt -eq 1 ]]
then
continue
fi
i=0
((snum=cnt-1))
v2=$(eval echo \"\$a$cnt\")
while (($i < $snum))
do
((i+=1))
v1=$(eval echo \"\$a${i}\")
# skip the line if it's equal to another
if [[ "$v1" = "$v2" ]]
then
((cnt-=1))
fi
done
done < my_file.log
# display the variables a1, a2,...a10
x=1
while (($x <= $cnt))
do
eval echo \"\$a${x}\"
((x+=1))
done
but how to cut of 2 first colums if I know that each line can have different number of words?
Thanks in advance!