perl awk OR sed, search between two timestamps

后端 未结 5 962
北荒
北荒 2021-01-24 20:44

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:32

    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-
    

提交回复
热议问题