perl awk OR sed, search between two timestamps

后端 未结 5 1485
死守一世寂寞
死守一世寂寞 2021-01-24 20:50

I have a file with following sample text. (The actual text is huge).

2014/05/08-19:15:44.544824-
2014/05/08-19:21:54.544824-
2014/0         


        
5条回答
  •  爱一瞬间的悲伤
    2021-01-24 21:18

    The awk and sed commands you show above won't work because they're doing pattern matching -- they're not comparing timestamps to each other in chronological terms (ie, if it doesn't see an exact 19:20:00 string, it will continue to the end even if it sees a 19:21:00 along the way).

    You could probably do it in perl using something similar to the two lines you show at the end where you're generating the timestamps, but in reverse to parse them, convert them to a time object and compare their values.

提交回复
热议问题