GNU/Linux >> Linux の 問題 >  >> Linux

Linuxのファイルから行、単語、文字を数える

wc は、ファイルの行数や単語数など、ファイルに関する詳細を取得できるLinuxユーティリティです。

コマンドの最も便利なオプションは次のとおりです。

-w, --words	prints the number of worlds
-l, --lines	prints the number of lines
-m, --chars	prints the number of characters

ファイル内のワールドの数をカウントするには:

# wc -w textfile.txt
root@www [/]# wc -w textfile.txt
8531 textfile.txt
root@www [/]#

ファイルの行数をカウントするには:

# wc -l textfile.txt
root@web [/]# wc -l textfile.txt
198 textfile.txt
root@web [/]#

ファイル内の文字数をカウントするには:

# wc -m textfile.txt
root@web [/]# wc -m textfile.txt
57678 textfile.txt
root@web [/]#

このコマンドの詳細については、 #man wcを実行してください。

参照:
wcmanファイル


Linux
  1. Linuxwcコマンド

  2. Linux シェル wc -c カウント文字数 +1

  3. Linux - 特定の行からファイルの最後までの grep

  1. Linuxでコマンドラインからファイルとディレクトリを削除する方法

  2. Linuxでコマンドラインからファイルを分割して結合する方法

  3. ファイル(タブとスペースを含む)から空白行を削除する方法は?

  1. ファイルの行数を数えますか?

  2. Linuxコマンドラインでファイルから特定の行を削除する

  3. Linux でファイルの行数を数える方法 (wc および nl コマンドの例)