使用正则表达式使用Grep命令

时间:2022-10-14 20:13:14
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x100
  Delay: 10x10

Above is the data of my txt file how can i get records after Delay: and before x100.please tell me the exact syntax?

上面是我的txt文件的数据如何在延迟之后获取记录:在x100之前。请告诉我确切的语法?

2 个解决方案

#1


2  

awk -F"[:x]” '$NF==100{ print $2 }' txt.file

#2


2  

If you have GNU grep, it actually can be done with grep.

如果你有GNU grep,它实际上可以用grep完成。

grep -Po '^Delay: \K[1-9][0-9]*' filename

#1


2  

awk -F"[:x]” '$NF==100{ print $2 }' txt.file

#2


2  

If you have GNU grep, it actually can be done with grep.

如果你有GNU grep,它实际上可以用grep完成。

grep -Po '^Delay: \K[1-9][0-9]*' filename