I'm trying to loop through some files in a directory and write the lines that are not included in the previous file into a text file. However, I only want to do this if one of the columns 1 or 5 deviates more than +-5 from the other.
The files in my directory contains input on the following form:
70 CYS 1 - 91 PRO 2 7.307
72 SER 1 - 91 PRO 2 7.103
77 TRP 1 - 88 PHE 2 8.730
78 PHE 1 - 82 GLU 2 5.840
79 GLU 1 - 81 GLY 2 5.407
82 GLU 2 - 77 TRP 1 8.786
90 GLU 2 - 72 SER 1 8.341
And I want the output
70 CYS 1 - 91 PRO 2 7.307
72 SER 1 - 91 PRO 2 7.103
77 TRP 1 - 88 PHE 2 8.730
90 GLU 2 - 72 SER 1 8.341
I did like this
file1=NONE
file2=NONE
for file in *.dat;do
file1=$file2
file2=$file
awk 'NR==FNR{c[$1,$2,$5,$6]++;next};c[$1,$2,$5,$6]==0' $file1 $file2 >> output.dat
done
and I have tried to include an if statement in several ways (first just with $1>70 to remove some complexity of the problem). How should I include an if statement into this awk line?
Aucun commentaire:
Enregistrer un commentaire