0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux][command] テキスト処理_表示_cat, nl, od, head, tail

Last updated at Posted at 2025-02-02

catコマンド

$ cat [オプション] [ファイル名...]
$ cat [引数]
オプション 由来 説明
default concatenate - ファイルを連結して表示する
- ファイル名を複数指定すれば順に結合して出力
 - ファイル名の場合: ファイルの内容を表示
 - 引数の場合: 引数を標準出力に表示
-n number - 空行を含めて行番号を付けて表示する
- nl -b aと同じ
-b number non-blank - 空行を除いて行番号を付けて表示する
- nl -b tと同じ

nlコマンド

$ nl [オプション] [ファイル名]
オプション 由来 説明
default number line - 空行を除いて行番号を付けて表示する
-b a 形式 body all - 空行を含めて行番号を付けて表示する
- cat -nと同じ
-b t 形式 body text - 空行を除いて行番号を付けて表示する
- デフォルト
- cat -bと同じ

odコマンド

$ od [オプション] [ファイル名]
オプション 由来 説明
default octal dump - ファイルを8進数(オクタル)形式で表示する
-t type 出力フォーマットを変更する(-t で指定した形式で表示)
-o
(-t o2)
octal 8進数形式でファイルの内容を表示する
-x
(-t x2)
hexadecimal 16進数形式でファイルの内容を表示する
-c
(-t c)
character ファイル内容をASCll文字として表示する(バイナリデータを対応する文字に変換)

headコマンド

$ head [オプション] [ファイル名]
オプション 由来 説明
デフォルト - ファイルの先頭10行を表示する
-n 行数
-行数
number - 表示する行数を指定(例:head -n 5 file.txt
-c バイト数 count - 先頭から指定したバイト数を表示

tailコマンド

$ tail [オプション] [ファイル名]
オプション 由来 説明
デフォルト - ファイルの末尾10行を表示する
-n 行数
-行数
number - 表示する行数を指定(例:tail -n 5 file.txt
-c バイト数 count - 末尾から指定したバイト数を表示
-f follow - ファイルの末尾に追記された内容をリアルタイムで表示(ログ監視などに便利)

Ping-t

cat

nl

od

head

tail

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?