Parsing 在UNIX中,在特定包含的字行之后打印行
我有问题,我想解析一个日志文件,如果上面的一行包含一个特定的单词,我想打印一行 比如说Parsing 在UNIX中,在特定包含的字行之后打印行,parsing,unix,printing,line,word,Parsing,Unix,Printing,Line,Word,我有问题,我想解析一个日志文件,如果上面的一行包含一个特定的单词,我想打印一行 比如说 line 1 containing : aaa line 2 containing : bbb 因此,它将打印出bbb,-A n选项,以grep打印匹配行后的下一行n grep -A 1 aaa logfile 如果您不想同时打印“aaa”,可以使用sed(1): 说明: -n don't print every line /aaa/ when this pattern is matched, e
line 1 containing : aaa
line 2 containing : bbb
因此,它将打印出bbb,
-A n
选项,以grep
打印匹配行后的下一行n
grep -A 1 aaa logfile
如果您不想同时打印“aaa”,可以使用sed(1): 说明:
-n don't print every line
/aaa/ when this pattern is matched, execute the block that follows
n advance to the next line
p print what's in the buffer
可能有你需要的
-n don't print every line
/aaa/ when this pattern is matched, execute the block that follows
n advance to the next line
p print what's in the buffer