てくてっく

コマ撮り作家系エンジニアです。日々地味ぃぃぃにつまづく技術的な問題について、備忘録として作ります。

catコマンドの使い方(復習)

名前は concatenate and print files

cat -- concatenate and print files

concatenateは「連結する」
連結してファイルを表示するコマンド?
表示だけじゃなかったん?

オプションは [-benstuv]

cat [-benstuv] [file ...]

-b 行番号をつける

-b Number the non-blank output lines, starting at 1.

1 CAT(1) BSD General Commands Manual CAT(1)

2 NNAAMMEE
3 ccaatt -- concatenate and print files

4 SSYYNNOOPPSSIISS
5 ccaatt [--bbeennssttuuvv] [_f_i_l_e _._._.]

-e non-printing charactersを表示する。行末に$をつける。

-e Display non-printing characters (see the -v option), and display
a dollar sign (`$') at the end of each line.

$
CAT(1) BSD General Commands Manual CAT(1)$
$
N^HNA^HAM^HME^HE$
c^Hca^Hat^Ht -- concatenate and print files$

NAMEとか一文字ずつなんか囲まれてる・・・。
col -b でこれを取り除いてたのか。


-n 出力行の行番号を表示する

-n Number the output lines, starting at 1.

1
2 CAT(1) BSD General Commands Manual CAT(1)
3
4 NNAAMMEE
5 ccaatt -- concatenate and print files
6

cat -b は、non-blankの出力行のみ、-nは出力行すべての、
行番号を表示する。
たしかに-nのほうが番号にふさわしい。

-s 空白行を整理する

-s Squeeze multiple adjacent empty lines, causing the output to be
single spaced.

Squeezeは「絞る」、adjacentは「隣接」、causingは「(結果を生み出す)原因」、
複数の空白行があるとき、それを1行だけに絞って表示する。
空白行が多くて見辛いときは良いかも。

-t non-printing charactersを表示する。タブは~Iで表示する。

-t Display non-printing characters (see the -v option), and display
tab characters as `^I'.

-u出力のバッファをdisableにする

-u Disable output buffering.

よくわからん

-v non-printing charactersを表示する。いくつか表示されるものが他と違う。

-v Display non-printing characters so they are visible. Control
characters print as `^X' for control-X; the delete character
(octal 0177) prints as `^?'. Non-ASCII characters (with the high
bit set) are printed as `M-' (for meta) followed by the character
for the low 7 bits.