r**b 发帖数: 4 | 1 Suppose I have a text file like this:
.
.
.
keyword1
......
keyword2
.
.
.
keyword1
......
keyword2
.
.
.
How to print lines containing "keyword1", "keyword2" and in between? |
s**a 发帖数: 79 | 2 You need to write your own script to do this. Any script language...you must
know one I assume.
sd
【在 r**b 的大作中提到】 : Suppose I have a text file like this: : . : . : . : keyword1 : ...... : keyword2 : . : . : .
|
t*******y 发帖数: 81 | 3 awk 'BEGIN{findkey1=0;}
{if ($0 ~ /keyword1/){findkey1=1;}
if(findkey1=1){print;}
if($0 ~ /keyword2/){findkey1=0;}
}' input-file
it should all be on the same line.
not sure about the actual syntax since I don't have
a reference book at hand, but you get the idea.
【在 r**b 的大作中提到】 : Suppose I have a text file like this: : . : . : . : keyword1 : ...... : keyword2 : . : . : .
|