Unix-commands-cat

提供:Dev Guides
移動先:案内検索

cat-Unix、Linuxコマンド

NAME

*cat* -ファイルのコンテンツを連結して印刷します。

概要

cat [Options] [File]...

説明

Catコマンドは、ファイル、または標準入力を標準出力に連結します。 FILEがない場合、またはFILEが-の場合、標準入力を読み取ります。

オプション

Tag Description
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonblank output lines
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank never more than one single blank line
-t equivalent to -vT
-T,--show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB. display this help and exit
--help display this help and exit
--version output version information and exit

2つのサンプルファイルを作成する

#sample.txt
This is a sample text file
#sample1.txt
This is a another sample text file

ファイルのコンテンツを表示します。

$ cat sample.txt
This is a sample text file

すべてのtxtファイルのコンテンツを表示します。

$ cat *.txt
This is a another sample text file
This is a sample text file

2つのファイルを連結します。

$ cat sample.txt sample1.txt > sample2.txt
$ cat sample2.txt
This is a sample text file
This is a another sample text file

ファイルの内容を変数に入れます。

$ variable_content = 'cat sample.txt'

link:/cgi-bin/printpage.cgi [__印刷]