我们有一个格式如下的日志文件:
22:59:59.372 test1 operation1
22:59:59.372 test2 operation2
22:59:59.359 test3 operation3
22:59:59.359 test4 operation4
我们想要消除毫秒并实现如下所示:
22:59:59 test1 operation1
22:59:59 test2 operation2
22:59:59 test3 operation3
22:59:59 test4 operation4
请你帮我用unix命令来实现这个目标。
答案 0 :(得分:0)
管道:
perl -ne '$_ =~ s/^(.{7})...(.*)/$1$2/; print $_'
像:
cat /tmp/in.txt | perl -ne '$_ =~ s/^(.{7})...(.*)/$1$2/; print $_'
或:
perl -ne '$_ =~ s/^(.{7})...(.*)/$1$2/; print $_' < /tmp/in.txt