Linux命令之查看檔案內容

來源:互聯網
上載者:User

標籤:linux 命令

1 cat:查看檔案內容

選項:-b    顯示行號,空白行不顯示行號

      -n    顯示行號,包括空白行

[[email protected] ~]#cat -b a.txt


2 more:分頁查看檔案內容,按空格查看下一頁,按q退出

[[email protected] ~]#more a.txt


3 less:分頁查看檔案內容,使用方式與vi類似,空格(下一頁)、b鍵(上一頁)、G(最後一行)、g(第一行)

[[email protected] ~]# less /etc/passwd


4 head:查看檔案頭部內容,預設為前10行

選項:-n    顯示前n行的內容

[[email protected] ~]# head -20 /etc/passwd


5 tail:查看檔案尾部的內容,預設為最後10行

選項:-n    顯示檔案末尾n行的內容

      -f    動態顯示檔案內容,通常用於查看日誌,ctrl+c退出

[[email protected] ~]# tail -20 /etc/passwd


6 wc:顯示檔案的行、單詞與位元組的統計資訊

選項:-c    顯示位元組的統計資訊

      -l    顯示行數統計資訊

      -w    顯示單詞統計資訊

[[email protected] ~]# wc -w a.txt


7 grep:尋找關鍵字並列印匹配的行

選項:-i    忽略大小寫

      -v    取反匹配

      --color    顯示顏色

[[email protected] ~]# grep --color minion a.txt


8 echo:顯示指定字串

選項:-n    不換行,預設echo輸出後會換行

[[email protected] ~]# echo -n c



本文出自 “一萬年太久,只爭朝夕” 部落格,請務必保留此出處http://zengwj1949.blog.51cto.com/10747365/1916434

Linux命令之查看檔案內容

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.