Linux基礎-文文書處理命令匯總

來源:互聯網
上載者:User

   本文將總結如下命令:

  wc: word count

  -l: 僅顯示行數

  -w: 僅顯示字數

  -c: 僅顯示byte大小

  cut:(remove sections from each line of files)從檔案的每行裡刪除固定的部分,用於匹配分隔字元,然後篩選需要的列內容

  -d: 指定分隔字元

  -f: 指定要顯示的欄位

  m: 第m列

  m,n: 第m和n列

  m-n: 第m到第n列

  sort 排序

  -f: 忽略字元大小寫

  -t: 指定分隔字元

  -k: 指定分隔字元的位置號

  -n: 以數值大小進行排序

  -u: 排序後去重

  uniq :(report or omit repeated lines)彙報或者忽略重複行, 容易忽略-c,可以統計重複次數

  練習:

  1、顯示當前系統上每個使用者的shell;

  # cut -d: -f1,7 /etc/passwd

  2、顯示當前系統上所有使用者使用的各種shell;

  # cut -d: -f7 /etc/passwd | sort | uniq

  3、取出/etc/inittab檔案的第7行;

  # head -n 7 /etc/inittab | tail -n 1

  4、取出/etc/passwd檔案中第7個使用者的使用者名稱;

  # head -n 7 /etc/passwd | tail -n 1 | cut -d: -f1

  5、統計/etc目錄下以大小寫p開頭的檔案的個數;

  # ls -d /etc/[pP]* | wc -l

        :更多精彩教程請關注三聯電腦教程欄目,三聯電腦辦公群:189034526歡迎你的加入

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.