perl awk OR sed, search between two timestamps

后端 未结 5 1523
死守一世寂寞
死守一世寂寞 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:17

    Why all the complexity?

    $ awk -F'[-.]' '"19:15:00"<=$2 && $2<="19:20:00"' file
    2014/05/08-19:15:44.544824-
    

    or less readably but more efficiently if the file is sorted:

    $ awk -F'[-.]' '$2>"19:20:00"{exit} $2>="19:15:00"' file
    2014/05/08-19:15:44.544824-
    

提交回复
热议问题