06/25 11:07:24 [INFO] *** CONTROL OUT bytes: 020106/25 11:07:24 [INFO]*** CONTROL IN bytes:080205063D715EB8F4740400200000FFE7010002000000000000000000000006/25 11:07:24 [INFO] hardware revision: 006/25 11:07:24 [INFO] dongle firmware version: 2.506/25 11:07:24 [INFO] dongle bluetooth address: 06:3D:71:5E:B8:F406/25 11:07:24 [INFO] CLIENT: [06/25 11:07:24] Dongle | Version|"majorVersion":2,"minorVersion":5,"deviceAddr":6,61,113,94,184,244],"flashEraseTime":1140,"firmwareStartAddress":8192,"firmwareEndAddress":124927,"ccIC":2,"hardwareRevision":0,"revision":0}06/25 11:07:24 [INFO] CLIENT: [06/25 11:07:24] Dongle | Set Power Level | 506/25 11:07:24 [INFO] Received message from client.06/25 11:07:24 [INFO] *** CONTROL OUT bytes: 020D050
所以我想通过将每个命令/部分放在一个新行上来清理它,比如这个,
06/25 11:07:24 [INFO] CLIENT: [06/25 11:07:24] Dongle | Set Power Level | 5
06/25 11:07:24 [INFO] Received message from client.
06/25 11:07:24 [INFO] *** CONTROL OUT bytes: 020D050
但我不确定从哪里开始。
答案 0 :(得分:4)
更新:评论合并在答案中!谢谢,Charles Duffy和pabouk。
假设您的字符串位于Comments
:
filename
为了更好的安全性,pabouk建议匹配更长的模式:
# bound to GNU sed, because of '-r/--regexp-extended'
sed -r 's:[0-9]{2}/[0-9]{2}:\n&:g' <filename
# without '-r':
sed 's:[0-9][0-9]/[0-9][0-9]:\n&:g' <filename
答案 1 :(得分:2)
awk 'BEGIN { RS="[0-9]{2}/[0-9]{2}"; } { print rt $0; rt = RT; }' < filename