I have the following text file for which I need to compare the values ββfrom each line, namely paragraphs 2-4 in relation to paragraphs 5-7. I am stuck with bash / awk / sed on this.
Sample data:
[hartford tmp]$ cat flist a1 1 2 3 xyz b1 3 2 1 zyx c1 1 2 3 1 2 3 d1 4 5 6 6 5 4 e1 abcabc f1 xyzxyz
It works with the following script, but its just unbearably slow, probably because all echo s.
[hartford tmp]$ cat pdelta.sh #!/bin/bash cat flist |while read rec; do f1="$(echo $rec | awk '{ print $1 }')" f2="$(echo $rec | awk '{ print $2 }')" f3="$(echo $rec | awk '{ print $3 }')" f4="$(echo $rec | awk '{ print $4 }')" f5="$(echo $rec | awk '{ print $5 }')" f6="$(echo $rec | awk '{ print $6 }')" f7="$(echo $rec | awk '{ print $7 }')" if [[ "x${f2} x${f3} x${f4}" != "x${f5} x${f6} x${f7}" ]]; then echo "$f1 DOES NOT MATCH" fi done
On startup, the output is exactly what I am looking for, but it is too slow when working with a 50k + file.
[hartford]$ ./pdelta.sh a1 DOES NOT MATCH b1 DOES NOT MATCH d1 DOES NOT MATCH
What is a more efficient way to do this?
source share