Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parsing 在UNIX中,在特定包含的字行之后打印行_Parsing_Unix_Printing_Line_Word - Fatal编程技术网

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