ファイルの行数を計算し、より多くの行を含む比較(BASH)

ファイルの行数を計算し、より多くの行を含む比較(BASH)

xファイルの行数を数え、どのファイルにさらに多くの行があるかを比較する必要があります。

私がしたことは、2つのファイルをインポートして比較することだけでした。 x個のファイルにする方法をご存知ですか?

echo Enter the filename read fn

echo Enter another file read fn1

for WORD in $(cat $fn) do
        echo "$WORD" done | wc -l

for WORD in $(cat $fn1) do
        echo "$WORD" done | wc -l

if (cat $fn | wc -l > cat $fn1 | wc -l) then
        echo First file has more lines than second file else if (cat $fn1 | wc -l > cat $fn | wc -l) then
        echo Second file has more lines than first file.

fi

ベストアンサー1

find . -name "*.txt" -exec wc -l '{}' \; | sort -n

線の寸法を学習したら、1行ずつ整列できます。

おすすめ記事