小的檔案可以用 cat, 或 vim

超大檔案如果只看特定行數可以搭配 sed

 

1. 列出第五行

 sed -n 5p file

2. 列出第五行, 第八行

 sed -n -e 5p -e 8p file

3. 列出第五到第八行

 sed -n 5,8p file

4.列出第五到第八行, 和第十行

 sed -n -e 5,8p -e 10p file

 

 

Reference:

https://unix.stackexchange.com/questions/288521/with-the-linux-cat-command-how-do-i-show-only-certain-lines-by-number

文章標籤
全站熱搜
創作者介紹
創作者 kk 的頭像
kk

kk

kk 發表在 痞客邦 留言(0) 人氣(56)