wcコマンドでファイルの単語数をカウントする方法
wcコマンドでファイルの単語数をカウントするには-wオプションを指定します。
オプションの説明
-w, --words print the word counts
-wオプションを指定した場合
$ cat test.txt This is a pen. $ wc -w test.txt 4 test.txt $ cat test2.txt Thisisapen. $ wc -w test2.txt 1 test2.txt $ cat test3.txt T h i s i s a p e n . $ wc -w test3.txt 11 test3.txt $ cat test4.txt これはペンです。 $ wc -w test4.txt 1 test4.txt