日より古いファイルを見つけて、削除する前に名前とサイズを出力します。

日より古いファイルを見つけて、削除する前に名前とサイズを出力します。

日付より古いファイルを見つけて削除する前に、名前とフルサイズをテキストファイルに印刷しようとしています。問題は、複数の(-exec)オプションを組み合わせるとエラーが発生することです。これは私のshファイルです。

#!/bin/bash
cache_location=$1
age=$2
date=`date +%d-%m-%Y`
find $cache_location -mtime $2 -path '*keyword*' -fprint deleted_cache_$date.log -exec du -k {} \; | awk '{total+=$1}END{print "TOTAL SIZE " total/1024/1024 "GB"}' >> deleted_cache_$date.log \; 
-exec echo {} | wc -l>> deleted_cache_$date.log \;
-exec rm -r {} \;

次にスクリプトを次のように呼び出します。

.\myscript.sh location +30

エラーのためスクリプトが停止しました。

awk: fatal: cannot open file `;' for reading (No such file or directory)
find: ‘du’ terminated by signal 13

ログファイルですべての結果を表示できます。探す注文する。

ベストアンサー1

おすすめ記事