ファイルの内容を表示するには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
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
10 # the directives.
↑空行は行としてカウントしない
P.S
ファイルの内容を行番号付きで表示するのもっと高い技術を身につけたいならこちら
<<関連記事>>
・tarコマンドで作成したアーカイブの内容を表示する
・Linuxでファイルコンテンツの検索をする
・tar.bz2ファイルを解凍して展開するには
・BZIP2形式でファイルを圧縮・解凍するには
・GZIP形式の圧縮ファイルを解凍する