我只想只在两个单词之间包含一个或多个空格的句子。



1. always  @    ( posedge clk  or     posedge rst )      //Test
2. always @ ( posedge clock )begin //or negedge reset) begin
3. always  @ (posedge clock or posedge reset)      //Test
4. always @ ( posedge clock ) //or negedge reset) begin


在这里,我只想grep序列号1和3。输出应为:

1. always  @    ( posedge clk  or     posedge rst )      //Test
3. always  @ (posedge clock or posedge reset)      //Test


我该如何grep?

最佳答案

以此作为输入文件(从问题源复制和粘贴):

$ cat >file
1. always  @    ( posedge clk  or     posedge rst )      //Test
2. always @ ( posedge clock )begin //or negedge reset) begin
3. always  @ (posedge clock or posedge reset)      //Test
4. always @ ( posedge clock ) //or negedge reset) begin


据我所知,您正在寻找的所有行中有两个或多个连续空格。在这种情况下:

$ grep '  ' file
1. always  @    ( posedge clk  or     posedge rst )      //Test
3. always  @ (posedge clock or posedge reset)      //Test

关于linux - 如何只重复两个单词之间可能包含一个或多个空格的句子,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31801337/

10-12 02:47