Find numbers after specific text in a string with RegEx

后端 未结 3 1251
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 15:00

I have a multiline string like the following:

2012-15-08 07:04 Bla bla bla blup
2012-15-08 07:05 *** Error importing row no. 5: The import of this line faile         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-03 15:20

    THere could be multiple ways , few simple ones shown below might help:-

    I took your log in a file called temp.txt.

    cat temp.txt | grep " Error importing row no." | awk -F":" '{print $2}' | awk -F"." '{print $2}'
    
    OR
    
    cat temp.txt | grep " Error importing row no." | sed  's/\(.*\)no.\(.*\):\(.*\)/\2/'
    

提交回复
热议问题