ファイルの最初のn行にある総単語数を計算するUnixコマンドを作成しますか?

ファイルの最初のn行にある総単語数を計算するUnixコマンドを作成しますか?

3最初の行の単語数を計算する方法は?

入力する:

There are many systems which are Unix-like in their architecture. 
Not able among these are the GNU/Linux distributions. 
The distinctions between Unix and Unix-like systems.
For distinctions between SUS branded UNIX architectures and other similar architectures, see Unix-like.

出力:28

ベストアンサー1

1行にawkを使用してください。

awk ' { gsub("[-/]"," ") } NR<4 { w+=NF };END { print w }' <filename>

おすすめ記事