Linux 文件去重

背景:

大量图片,但个图片只是名字不一样,内容一样,需要去重

date;find /home/admin/image -name *.jpeg | xargs md5sum|sort >allfiles;cat allfiles |uniq -w 32 > uniqfiles;comm allfiles uniqfiles -2 |cut -c 35-|wc -l;date
date;find /home/admin/image -name *.jpeg | xargs md5sum|sort >allfiles;cat allfiles |uniq -w 32 > uniqfiles;comm allfiles uniqfiles -2 |cut -c 35-|tr '\n' '\0'|xargs -n `getconf ARG_MAX`  rm;date

PS:

1. rm 可支持带的文件数以 getconf ARG_MAX为准,

2. 不使用exec,因为exec一次只能rm一个,xargs可支持带多个参数;

posted on 2019-08-02 09:50  旧楚布衣  阅读(1105)  评论(0编辑  收藏  举报