LINUX

LINUX CAT指令

介紹

cat指令用來串接檔案並輸出到螢幕上。

語法

cat [options] [files]
Code language: Bash (bash)

常用的options

-T Print tabs as ^|. -E Print newlines as $. -v Print other nonprinting characters in a human-readable format. -n Prepend line numbers to every line. -b Prepend line numbers to nonblank lines. -s Squeeze each sequence of blank lines into a single blank line.
Code language: plaintext (plaintext)

範例

假設現在有兩個檔案:

file1.txt: file1 header file1 content file1 footer ----------分隔線---------- file2.txt: file2 header file2 content file2 footer
Code language: plaintext (plaintext)

你可以串接這兩個檔案並輸出到螢幕上:

⤍ cat file1.txt file2.txt file1 header file1 content file1 footer file2 header file2 content file2 footer
Code language: Bash (bash)

如果只有一個檔案,相當於檢視這個檔案:

⤍ cat file1.txt file1 header file1 content file1 footer
Code language: Bash (bash)

發佈留言