Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2722

重複ファイルを1つだけ残して削除するコマンド

$
0
0
以下の1行を整理したいディレクトリで実行 md5sum * | awk '!colname[$1]++{print}' | awk '{print "-not -name " $2}' | paste -sd " " | xargs -i sh -c 'find -type f {}' | xargs rm ハッシュ値が同じなら同一とみなしています(普通は衝突しないので問題ないと思いますが、念のためバックアップはとってください) ファイル名が同じでも中身は一緒ってファイルを見つけて消したい時にお使いください。 参考にさせていただいた記事 http://akiniwa.hatenablog.jp/entry/2014/04/04/203256 https://qiita.com/soymsk/items/7c1621ffca4d0f7ad678 https://qiita.com/piroor/items/55ff672cb9f8e375e659

Viewing all articles
Browse latest Browse all 2722

Trending Articles