Linux命令詳解之—cat命令,linux命令詳解cat

來源:互聯網
上載者:User

Linux命令詳解之—cat命令,linux命令詳解cat

cat命令的功能是串連檔案或標準輸入並列印,今天就為大家介紹下Linux中的cat命令。

更多Linux命令詳情請看:Linux命令速查手冊

Linux 的cat命令通常用來顯示檔案內容,也可以用來將幾個檔案串連起來顯示,或者從標準輸入讀取內容並顯示,常與重新導向符號配合使用。

一、Linux cat命令文法格式
cat [OPTION]... [FILE]..

參數說明:

-A, --show-all           等價於 -vET-b, --number-nonblank    對非空輸出行編號-e                       等價於 -vE-E, --show-ends          在每行結束處顯示 $-n, --number     對輸出的所有行編號,由1開始對所有輸出的行數編號-s, --squeeze-blank  有連續兩行以上的空白行,就代換為一行的空白行 -t                       與 -vT 等價-T, --show-tabs          將跳格字元顯示為 ^I-u                       (被忽略)-v, --show-nonprinting   使用 ^ 和 M- 引用,除了 LFD 和 TAB 之外
二、Linux cat命令使用執行個體

1)顯示檔案內容

#cat file1This is a test file.Welcome to linuxdaxue.com!This is cat command test.

2)把file1內容加上行號輸入到file2中

#cat -n file1 > file2[root@/root/linuxdaxue.com/testDir]#cat file2     1    This is a test file.     2    Welcome to linuxdaxue.com!     3    This is cat command test.

 

3)清空file2內容

#cat /dev/null > file2#cat file2#

4)Linux tac命令

tac就是cat反過來,功能也與cat正好相反,用來將檔案從後向前輸出。

以下是兩個命令的區別

[root@/root/linuxdaxue.com/testDir]#cat file1This is a test file.Welcome to linuxdaxue.com!This is cat command test.[root@/root/linuxdaxue.com/testDir]#tac file1This is cat command test.Welcome to linuxdaxue.com!This is a test file.

好了,有關Linux cat命令的內容就為大家介紹到這裡,更多Linux命令詳情請看:Linux命令速查手冊

 

  • 著作權聲明:本站原創文章,於3個月前,由Linux大學(Linuxdaxue.com)發表,共 1015字。
  • 轉載請註明:Linux命令詳解之—cat命令 | 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.