目前还不完全清楚你的目标是什么,但这里有一些可以作为一个开始的东西。print
根据需要,将语句替换为更实质性的处理。
awk '
/^[ 0-9][0-9] / {
# This is a record header line. Check if it is a TX.
inTx = ($0 ~ / TX\([0-9]*\)$/);
if (inTx) {
print "Start of TX record.";
next; # Avoid printing the header line below.
}
}
inTx { print "TX:", $0; }
' file.txt
这是一个更强大的示例文件,以使其更清楚脚本的作用:
1 [001:01.0] [ 2] IOCTL 048477589
...
...
28 [002:02.0] [ 2] TX(56)
81480d0d 0a524141 435a5955 5705243 .H...RAACZYW RC
43544848 41303033 32203034 3032325 CTHHA0032 04025
332d4343 43432d2d 52435554 4848412 3-CCCC--RCETHHA
1 [001:01.0] [ 2] IOCTL 048477589
2 [dsfsdsdf] [ 2] BLORT
29 [002:02.0] [ 2] TX(77)
abbababa 0a524141 435a5955 5705243 STUFFSTUFFSTUFF
43544848 bbbbbbbb 32203034 d0d0d0d CTHULUCTHULUCTH
332d4343 43432d2d cccccccc 4848412 BLORTZORCHFNORD
1 [001:01.0] [ 2] IOCTL 048477589
2 [dsfsdsdf] [ 2] BLORT
运行脚本的成绩单:
Start of TX record.
TX: 81480d0d 0a524141 435a5955 5705243 .H...RAACZYW RC
TX: 43544848 41303033 32203034 3032325 CTHHA0032 04025
TX: 332d4343 43432d2d 52435554 4848412 3-CCCC--RCETHHA
Start of TX record.
TX: abbababa 0a524141 435a5955 5705243 STUFFSTUFFSTUFF
TX: 43544848 bbbbbbbb 32203034 d0d0d0d CTHULUCTHULUCTH
TX: 332d4343 43432d2d cccccccc 4848412 BLORTZORCHFNORD