thunderkid
Technical User
I am trying to modify a current awk script that PHV provided on an earlier thread (271-801668). I have provided my current task and PHV’s script for earlier task.
Here is sample of input file:
123 <time1_data> xxxx bbb1 cccc1 dddd1
123 <time2_data> xxxx bbb1 cccc1 dddd1
234 <time3_data> xxxx bbb2 cccc2 dddd2
234 <time4_data> xxxx bbb2 cccc2 dddd2
234 <time5_data> xxxx bbb2 cccc2 dddd2
345 <time6_data> xxxx bbb3 cccc3 dddd3
345 <time7_data> xxxx bbb3 cccc3 dddd3
345 <time8_data> xxxx bbb3 cccc3 dddd3
123 <time1_data> yyyy bbb1 cccc1 dddd1
123 <time2_data> yyyy bbb1 cccc1 dddd1
234 <time3_data> yyyy bbb2 cccc2 dddd2
234 <time4_data> yyyy bbb2 cccc2 dddd2
234 <time5_data> yyyy bbb2 cccc2 dddd2
345 <time6_data> yyyy bbb3 cccc3 dddd3
345 <time7_data> yyyy bbb3 cccc3 dddd3
345 <time8_data> yyyy bbb3 cccc3 dddd3
345 <time9_data> yyyy bbb3 cccc3 dddd3
.
.
desired output:
The first extraction should pick the first record when fields 1,3,4,5 & 6 are the same:
123 <time1_data> xxxx bbb1 cccc1 dddd1
234 <time3_data> xxxx bbb2 cccc2 dddd2
345 <time6_data> xxxx bbb3 cccc3 dddd3
123 <time1_data> yyyy bbb1 cccc1 dddd1
234 <time3_data> yyyy bbb2 cccc2 dddd2
345 <time6_data> yyyy bbb3 cccc3 dddd3
In another extraction I need to pick the second record when fields 1,3,4,5 & 6 are the same:
123 <time2_data> xxxx bbb2 cccc2 dddd2
234 <time4_data> xxxx bbb2 cccc2 dddd2
345 <time7_data> xxxx bbb3 cccc3 dddd3
123 <time2_data> yyyy bbb2 cccc2 dddd2
234 <time4_data> yyyy bbb2 cccc2 dddd2
345 <time7_data> yyyy bbb3 cccc3 dddd3
The following awk script worked great when I was only used fields 1 & 2
awk -v ind=1or2 '++a[$1]==ind' </path/to/file
Now I would like to build script to compare fields as described above. I have tried to modify this script but have not had any success. Thanks for your inputs.
thunderkid
Here is sample of input file:
123 <time1_data> xxxx bbb1 cccc1 dddd1
123 <time2_data> xxxx bbb1 cccc1 dddd1
234 <time3_data> xxxx bbb2 cccc2 dddd2
234 <time4_data> xxxx bbb2 cccc2 dddd2
234 <time5_data> xxxx bbb2 cccc2 dddd2
345 <time6_data> xxxx bbb3 cccc3 dddd3
345 <time7_data> xxxx bbb3 cccc3 dddd3
345 <time8_data> xxxx bbb3 cccc3 dddd3
123 <time1_data> yyyy bbb1 cccc1 dddd1
123 <time2_data> yyyy bbb1 cccc1 dddd1
234 <time3_data> yyyy bbb2 cccc2 dddd2
234 <time4_data> yyyy bbb2 cccc2 dddd2
234 <time5_data> yyyy bbb2 cccc2 dddd2
345 <time6_data> yyyy bbb3 cccc3 dddd3
345 <time7_data> yyyy bbb3 cccc3 dddd3
345 <time8_data> yyyy bbb3 cccc3 dddd3
345 <time9_data> yyyy bbb3 cccc3 dddd3
.
.
desired output:
The first extraction should pick the first record when fields 1,3,4,5 & 6 are the same:
123 <time1_data> xxxx bbb1 cccc1 dddd1
234 <time3_data> xxxx bbb2 cccc2 dddd2
345 <time6_data> xxxx bbb3 cccc3 dddd3
123 <time1_data> yyyy bbb1 cccc1 dddd1
234 <time3_data> yyyy bbb2 cccc2 dddd2
345 <time6_data> yyyy bbb3 cccc3 dddd3
In another extraction I need to pick the second record when fields 1,3,4,5 & 6 are the same:
123 <time2_data> xxxx bbb2 cccc2 dddd2
234 <time4_data> xxxx bbb2 cccc2 dddd2
345 <time7_data> xxxx bbb3 cccc3 dddd3
123 <time2_data> yyyy bbb2 cccc2 dddd2
234 <time4_data> yyyy bbb2 cccc2 dddd2
345 <time7_data> yyyy bbb3 cccc3 dddd3
The following awk script worked great when I was only used fields 1 & 2
awk -v ind=1or2 '++a[$1]==ind' </path/to/file
Now I would like to build script to compare fields as described above. I have tried to modify this script but have not had any success. Thanks for your inputs.
thunderkid