2015-08-30 68 views

回答

0

嘗試這種模式:

\A(.*\r?\n){3}|(\r?\n.*){3}\z 

這裏用Rubular測試它:http://rubular.com/r/MfiF4tRyk3

+0

我在Powergrep測試過,我確認這一個工作,第一個答案沒有,謝謝你的幫助。 – Jim8645

0

檢查本作的前三行(demo上regex101.com):

\A(^.*$\r?\n){3} 

,這在過去三年(demo):

(^.*$\r?\n){3}\z 
0

您不能使用grepgrep(1)作品行相等保證。你有一個更好的解決方案的sed(1)在下面的代碼:

sed -e '1d;$d' file.txt >output.txt 

我要刪除線1-3($-3)-$嘗試

sed -e '1,3d;$-3,$d' file.txt >output.txt 

對不起,我從來沒有使用powergrep所以我不能以這種方式幫助你。

相關問題