ペチパーノート

WEB開発系Tipsブログです。

空ファイルを一括削除

find {dir} -empty -delete

やってみる。

$ touch test1.txt
$ touch test2.txt
$ echo 'hoge' > test3.txt
$ ll
-rw-rw-r-- 1 vagrant vagrant    0  8月 28 13:25 test1.txt
-rw-rw-r-- 1 vagrant vagrant    0  8月 28 13:25 test2.txt
-rw-rw-r-- 1 vagrant vagrant    5  8月 28 13:25 test3.txt

# 空ファイルを削除
$ find . -empty -delete
$ ll
-rw-rw-r-- 1 vagrant vagrant    5  8月 28 13:25 test3.txt

0バイトのファイルだけ消えた!