特定のファイルサイズまでディレクトリに見つかったファイルの合計を一覧表示する良い方法は何ですか?

特定のファイルサイズまでディレクトリに見つかったファイルの合計を一覧表示する良い方法は何ですか?

このリストは、簡単に移動できるようにタールボールを作成するために使用されます。これまで私が思いついた内容は次のとおりです。 10 GB を超えるファイルをファイルに追加します。

find .  -type f -exec ls -al {} + | awk '{ total += $5 }; {print $9}; {if (total > 10000000000) {print total; total = 0  }}; END { print total }' > /tmp/testfile.txt

各タールボールに一意の名前を付けたいのですが、すべての結果を/tmp/testfile.txtに保存します。

これを試してみましたが、少し面倒そうです。

find . -type f -exec ls -al {} + | awk '{ filenumber };{ total += $5 }; {print $9}; {if (total > 10000000000) {print total; total = 0; filenumber++;print "This is filenumber"filenumber".tar" }}; END { print total }' > /tmp/testfile.txt

これが私が思いついたものです -

 find ./ -type f -exec ls -al {} + | awk 'BEGIN { filenumber };{ total += $5 }; {print $9 > "filename"filenumber".txt"}; {if (total > 10000000000) {print total; total = 0; filenumber++;print "This is filename"filenumber".txt" }}; END { print total }' > filecheck.txt

そのコマンドの後に結果をコマンドに提供します。

for file in $( find . -name "filename*.txt" -type f );do tar -cvf "$file.tar" -T "$file"; done

ベストアンサー1

おすすめ記事