0
這裏我正在練習grep命令.Am不清楚以下grep條件是如何工作的?Grep條件匹配如何工作?
a_file:
boot
record
boots
process
broken
commands
我曾嘗試下面的命令: -
1. grep -A0 "boo" a_file
result:
boot
--
boots
2.grep -A1 "boo" a_file
result:
boot
record
boots
process
3.grep -A2 "boo" a_file
result:
boot
record
boots
process
broken
4.grep -A3 "boo" a_file
result:
boot
record
boots
process
broken
commands
Note:I had studied this grep command from terminal man grep.
我的查詢:
1.What is the purpose of switch -A?
2.How the context lines are ordered for every numeric values (i.e 1,2,3)?
你試圖理解你的第二個問題? 'grep -A'如何執行它的工作? – CWLiu
A表示匹配上下文之後。如果我給出A2,它將查找搜索字符串(即boo)。在由於A2匹配的行之後,它將在匹配字符串後面打印下兩行。這就是我從命令中理解的內容。 @CWLiu – PathFinder
是的,你的理解基本上是正確的,你的第二個問題是什麼,詳述它。這將幫助這裏的人爲您提供更準確的答案。 – CWLiu