I'm trying to find a string in a txt format and each time it's found then look for an specific string to change for another string and avoiding reading the first sequence of the line.
Imagine the nexts hexadecimal txt:
0000 09 06 07 04 00 00 01 00 1d 03 4b 2c a1 2a 02 01
0010 b7 09 01 47 30 22 a0 0a 80 08 33 04 03 92 22 14
0020 17 f0 a1 0b 80 00 81 00 84 01 00 86 00 85 00 83
0030 07 91 94 71 06 00 07 19
0000 09 06 07 04 00 00 01 00 2b 03 4b 27 a1 25 02 01
0010 00 09 01 66 30 1d a0 0a 80 08 33 04 03 92 22 14
0020 17 f0 a1 06 82 00 84 00 85 00 82 07 91 94 71 06
0030 00 07 19
Expected output:
0000 09 06 07 04 00 00 01 00 1d 03 4b 2c a1 2a 02 01
0010 b7 09 01 47 30 22 a0 0a 80 08 33 04 03 92 22 14
0020 12 f0 a1 0b 80 00 81 00 84 01 00 86 00 85 00 83
0030 07 91 94 71 06 00 07 19
0000 09 06 07 04 00 00 01 00 2b 03 4b 27 a1 25 02 01
0010 00 09 01 66 30 1d a0 0a 80 08 33 04 03 92 22 14
0020 12 f0 a1 06 82 00 84 00 85 00 82 07 91 94 71 06
0030 00 07 19
I need that each time I encounter a 4b sequence to look for 14 sequence and if found look in the next line the first string, which is in this case 17 and if this string is 17 change to 12. What you have on the left is a sequence which gives you the line of the txt you are, so that it's not interesting to analysis because it's repeated in each paragraph
What I have is the next:
gawk ' { for ( i = 1; i <= NF; ++i ) {
if ( $i == "4b" )
r = 1
if ( r && ($i == "14" ))
t = 1
if ( r && t && $i == "17") {
r = 0
t = 0
$i = "12"
}
}
}
1 ' example.txt example2.txt
However, I don't know well how to avoid reading the first xxxx sequence of each line