ファイルの内容を行番号付きで表示する


無料Linux入門マニュアル無料ダウンロード

今だけ2,200円のLinux入門PDFマニュアルが【数量限定】で無料ダウンロードできます。
Linux入門マニュアル無料ダウンロードはこちらをクリック

ファイルの内容を表示するにはcatコマンドをしようしますが、オプションなしで実行した場合、単に内容が表示されるだけです。行番号を付けてファイル内容を表示するには、catコマンドにオプション-nを付けて実行します。

ファイルの空行に行番号を付けたくない場合は、オプション-bを付けます。


行番号付きでファイルの内容を表示します。

[pakira@Dolphin conf]$ cat -n httpd.conf
1 ##
2 ## httpd.conf -- Apache HTTP server configuration file
3 ##
4
5 #
6 # Based upon the NCSA server configuration files originally by Rob McCool.
7 #
8 # This is the main Apache server configuration file. It contains the
9 # configuration directives that give the server its instructions.
10 # See for detailed information about
11 # the directives.

↑httpd.confファイルを行番号付きで内容表示させます。


[pakira@Dolphin conf]$ cat -b httpd.conf
1 ##
2 ## httpd.conf -- Apache HTTP server configuration file
3 ##

4 #
5 # Based upon the NCSA server configuration files originally by Rob McCool.
6 #
7 # This is the main Apache server configuration file. It contains the
8 # configuration directives that give the server its instructions.
9 # See for detailed information about
10 # the directives.

↑空行は行としてカウントしない


無料Linux入門マニュアル無料ダウンロード

今だけ2,200円のLinux入門PDFマニュアルが【数量限定】で無料ダウンロードできます。
Linux入門マニュアル無料ダウンロードはこちらをクリック


<<関連記事>>
・tarコマンドで作成したアーカイブの内容を表示する
・Linuxでファイルコンテンツの検索をする
・tar.bz2ファイルを解凍して展開するには
・BZIP2形式でファイルを圧縮・解凍するには
・GZIP形式の圧縮ファイルを解凍する

Linux入門マニュアル無料ダウンロード