2017-08-28 82 views
-5

内容:相关值作为输出的Linux grep命令

1. Name : Jack 
    Address : Toronto 
    Age : 21 
2. Name : Mitchelle 
    Address : Newyork 
    Age : 67 
3. Name : John 
    Address : Toronto 
    Age : 33 

命令grep Toronto给我

Address : Toronto 
Address : Toronto 

预期结果:

1. Name : Jack 
    Address : Toronto 
    Age : 21 
3. Name : John 
    Address : Toronto 
    Age : 33 
+1

你问“我怎样才能得到整个地址块,而不是只有线”? –

回答

1

对于你的情况,你有一条线主导和你关心的一行尾随上下文,所以grep -C1 Toronto input应该这样做。

+0

工程就像魅力。谢谢。 –