歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux查找除了中間幾行的內容

要求:
Linux哪個命令可以列出test文件中除3到10行外的所有內容?

很多文章都有介紹如何查看中間幾行的內容比如查看test文件中3-10行,比較常用的就有三種方法
1、sed -n '3,10p' test
2、cat test | head -n 10 | tail -n +3
3、cat test | tail -n +3 | head -n 7
tail -n 3:顯示最後3行
tail -n +3:從第3行開始顯示,一直到最後
head -n 3:顯示前面3行

這裡的要求是除了中間3-10行以外的內容
答案是:  cat test | sed 3,10d

這裡不解釋了,不懂的可以man 一下

Copyright © Linux教程網 All Rights Reserved