Grep如何抓取前一行後兩行 - Linux

By Leila
at 2011-11-26T13:39
at 2011-11-26T13:39
Table of Contents
我覺得版本的問題吧?
我測試了一下,以下是測試檔:
/***************************/
grep_test.txt:
AAA
BBB
CCC
DDD
EEE
FFF
GGG
/*************************/
測試結果:
bigdick@bigdick:~$ grep "AAA" grep_test.txt
AAA
bigdick@bigdick:~$ grep -A2 "AAA" grep_test.txt
AAA
BBB
CCC
bigdick@bigdick:~$ grep -B1 -A2 "CCC" grep_test.txt
BBB
CCC
DDD
EEE
bigdick@bigdick:~$ grep -V
GNU grep 2.6.3 <---------------你要不要對一下版本?我是用Debian6.0
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
bigdick@bigdick:~$
--
我測試了一下,以下是測試檔:
/***************************/
grep_test.txt:
AAA
BBB
CCC
DDD
EEE
FFF
GGG
/*************************/
測試結果:
bigdick@bigdick:~$ grep "AAA" grep_test.txt
AAA
bigdick@bigdick:~$ grep -A2 "AAA" grep_test.txt
AAA
BBB
CCC
bigdick@bigdick:~$ grep -B1 -A2 "CCC" grep_test.txt
BBB
CCC
DDD
EEE
bigdick@bigdick:~$ grep -V
GNU grep 2.6.3 <---------------你要不要對一下版本?我是用Debian6.0
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
bigdick@bigdick:~$
--
Tags:
Linux
All Comments
Related Posts
centos 5.5 在二代I5電腦 裝不起來

By Oscar
at 2011-11-26T01:39
at 2011-11-26T01:39
哪些二手書店有linux相關書籍(台北)

By Edwina
at 2011-11-25T15:10
at 2011-11-25T15:10
eclipse3.7??

By Skylar DavisLinda
at 2011-11-25T13:45
at 2011-11-25T13:45
bash 新手. 請幫我看程式寫的對不對

By Brianna
at 2011-11-25T12:11
at 2011-11-25T12:11
root的聲音不見了, 一般使用者的還在

By Iris
at 2011-11-25T11:50
at 2011-11-25T11:50