Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 grep 命令来提取文本文件中包含特殊模式的那些行,但我也想提取这些特定行的下一行。可以使用grep吗?
您可以使用以下选项指定匹配后要打印的行数-A:
-A
grep -A1 pattern file
演示:
$ cat file line one line two line three $ grep -A1 'one' file line one line two
下次man grep!
man grep