Hi all,
I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like:
<date1>|<data1>|<url1>|<result1>
<date2>|<data2>|<url2>|<result2>
<date3>|<data3>|<url3>|<result3>
<date4>|<data4>|<url4>|<result4>
What I want to do is compare first line with second, second with third and so on to see if url1 is same as url2, url2 is same as url3 and so on.
I am trying to do this by copying the details of Test.log in a file File1.txt (I am going to do this periodically, maybe few times a day).
Then read File1.txt line by line and get url1 in a variable say Var1 by using
cut -d '|' -f2 <line1 of File1.txt>
and somehow be able to compare it with variable Var2 which I am hoping to get by using
cut -d '|' -f2 <line2 of File1.txt>
Problem's I am facing here are -
1) Cut is treating each space separated word as a field while I try to use it while reading File1.txt line by line in a loop like:
while i in `cat File1.txt`
do
cut -d '|' -f2 $i
done
OR
while read i
do
cut -d '|' -f2 $i
done < File1.txt
2) I have no idea how to be able to compare url1 with url2, url2 with url3 and so on.
Can anyone please help me here if what I am trying is even possible and if it is then how can I do it.
Thanks in advance.