あなたが実際にパイピングされているrmの出力を入力しますfind。何がしたいことの出力を使用することであるfindとして、引数にrm:
find -type f -name '*.sql' -mtime +15 | xargs rm
xargs標準入力を別のプログラムの引数に「変換」するコマンドです。または、より正確にmanページに配置するため、
標準入力からコマンドラインを構築して実行する
ファイル名に空白文字を含めることができる場合は、それを修正する必要があることに注意してください。
find -type f -name '*.sql' -mtime +15 -print0 | xargs -0 rm
しかし、実際にfindは、これのショートカットがあり-deleteます:オプション:
find -type f -name '*.sql' -mtime +15 -delete
の次の警告に注意してくださいman find。
Warnings: Don't forget that the find command line is evaluated
as an expression, so putting -delete first will make find try to
delete everything below the starting points you specified. When
testing a find command line that you later intend to use with
-delete, you should explicitly specify -depth in order to avoid
later surprises. Because -delete implies -depth, you cannot
usefully use -prune and -delete together.
PS 標準入力ではファイル名を想定していないrmため、直接にパイプすることはオプションではないことに注意してくださいrm。あなたが現在行っていることは、それらを逆方向にパイプすることです。