0

我有这样的输出

00:00.0 0600: 8086:2e20 (rev 03)
00:01.0 0604: 8086:2e21 (rev 03)
00:03.0 0780: 8086:2e24 (rev 03)
00:19.0 0200: 8086:10ce
00:1a.0 0c03: 8086:3a37
00:1a.1 0c03: 8086:3a38
00:1a.2 0c03: 8086:3a39
00:1a.7 0c03: 8086:3a3c
00:1b.0 0403: 8086:3a3e
00:1c.0 0604: 8086:3a40
00:1c.2 0604: 8086:3a44
00:1c.3 0604: 8086:3a46
00:1d.0 0c03: 8086:3a34
00:1d.1 0c03: 8086:3a35
00:1d.2 0c03: 8086:3a36
00:1d.7 0c03: 8086:3a3a
00:1e.0 0604: 8086:244e (rev 90)
00:1f.0 0601: 8086:3a18
00:1f.2 0106: 8086:3a22
00:1f.3 0c05: 8086:3a30
01:00.0 0300: 10de:0640 (rev a1)
03:00.0 0101: 11ab:6101 (rev c0)

我需要将每一行的输出作为:

610111ab <-- Last Line
064010de <-- Line Before Last One
4

4 回答 4

2

这可能会有所帮助

echo "03:00.0 0101: 11ab:6101 (rev c0)" | gawk 'BEGIN{FS="("}; { print $1 }' | gawk 'BEGIN{FS=":"; OFS="" };{ print $4,$3 }' | tr -d ' '
于 2013-10-10T17:17:23.910 回答
2

解决方案:

re="([0-9a-f]{4}):([0-9a-f]{4})"
猫输出.txt | 读 l ; 做 [[ $l =~ $re ]] && echo ${BASH_REMATCH[2]}${BASH_REMATCH[1]}; 完毕
于 2013-10-10T17:56:14.433 回答
1
sed 's/.*: \(....\):\(....\).*/\2\1/'

我也对每行所需的输出感到困惑。如果您希望它以相反的顺序输出,请将sed输出通过管道传输到tac.

于 2013-10-10T17:19:47.267 回答
1

awk 解决方案:

awk -F':| ' '{print $6$5}' output
于 2013-10-10T17:22:04.143 回答