How can I use findstr with newline regular expression

后端 未结 4 1305
天涯浪人
天涯浪人 2020-12-21 14:51

I\'m on windows dos prompt. I have log file which contains log like:

Timestamp: Order received for Item No. 26551
Timestamp: Exception: OutOfRangeException
T         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-21 15:12

    If you can download tools, here's a Ruby for Windows command you can use.

    C:\work>ruby -ne "print gets.split.last if /Exception/" file
    23423
    C:\work>type file
    Timestamp: Order received for Item No. 26551
    Timestamp: Exception: OutOfRangeException
    Timestamp: Message: Inventory Item is not stock. Item No. 23423
    Timestamp: Order received for Item No. 23341
    
    C:\work>ruby -ne "print gets.split.last if /Exception/" file
    23423
    

提交回复
热议问题