0
我使用下面的命令從小型機與時間戳日誌中的數據(串口):如何擺脫minicom輸出中的怪異字符?
minicom -D /dev/ttyUSB0 -b 9600 | (while read line; do echo "$(date +%Y%m%d:%H%M%S), ${line}"; done)| tee -a out.txt
中out.txt文件中記錄的數據是:
20151006:145139, [20;47H [21;1H1 some data
20151006:145140, [20;47H [21;1H2 some data
20151006:145141, [20;47H [21;1H3 some data
20151006:145142, [20;47H [21;1H4 some data
20151006:145143, [20;47H [21;1H5 some data
20151006:145144, [20;47H [21;1H6 some data
我的事了奇怪的字符「[20; 47H [21; 1 H」是回車和線路長度,我所要的輸出被保存在out.txt如以下:
20151006:145139, 1 some data
20151006:145140, 2 some data
20151006:145141, 3 some data
20151006:145142, 4 some data
20151006:145143, 5 some data
20151006:145144, 6 some data