hi My requirement is this:
I have a file having around 100000 records pipe delimited. Now I want to compare record 1 with record 2 and similarly record3 with record 4, this goes on.. For this purpose i put a script as follows:
#!bin/ksh
ct_line=1
nxt_line=`expr ${ct_line} + 1`
awk -F "|" -v i=${ct_line} -v j=${nxt_line} '{print i j} NR==i {
ct_dt=$1
ct_name=$2
}
NR==j {
nxt_dt=$1
nxt_name=$2
}
{print ct_dt nxt_dt}
i+=1
j=i+1
' <infile.txt >outfile.txt
Expected output:
1 2
20090501 20090502
Actual Output:
1 2
20090501
Its not all processing NR==j.. Why??
If there is any otehr way to do it in awk??
I mean, I need to read two lines at a time and assign their values to respective variables and compare..?/
Its an urgent requirement.. plz help