我有一个日志,我想打印两个日期之间的日志中的所有行02/04/2015:14:23:00
,02/04/2015:14:23:59
sed单线的另一种方法: sed -n '/start/,/end/p' log.txt
$ cat /tmp/log.txt
before
before
before
a log line containing 02/04/2015:14:23:00 and some other stuff
between
between
a log line containing 02/04/2015:14:23:59 and some other stuff
after
after
$ sed -n '/02\/04\/2015:14:23:00/,/02\/04\/2015:14:23:59/p' /tmp/log.txt
a log line containing 02/04/2015:14:23:00 and some other stuff
between
between
a log line containing 02/04/2015:14:23:59 and some other stuff
请注意,如果开始标记和结束标记在同一行中,它将无法按预期工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句