我输出像这样
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
答案 0 :(得分:2)
这可以帮助
echo "03:00.0 0101: 11ab:6101 (rev c0)" | gawk 'BEGIN{FS="("}; { print $1 }' | gawk 'BEGIN{FS=":"; OFS="" };{ print $4,$3 }' | tr -d ' '
答案 1 :(得分:2)
纯bash解决方案:
re="([0-9a-f]{4}):([0-9a-f]{4})" cat output.txt | while read l ; do [[ $l =~ $re ]] && echo ${BASH_REMATCH[2]}${BASH_REMATCH[1]}; done
答案 2 :(得分:1)
sed 's/.*: \(....\):\(....\).*/\2\1/'
我也对每行所需的输出感到困惑。如果您想以相反的顺序排列,请将sed
输出管道输入tac
。
答案 3 :(得分:1)
Awk解决方案:
awk -F':| ' '{print $6$5}' output