Chinaunix首页 | 论坛 | 博客
  • 博客访问: 442489
  • 博文数量: 112
  • 博客积分: 4451
  • 博客等级: 上校
  • 技术积分: 1063
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-23 10:19
个人简介

更多精品http://shop65927331.taobao.com

文章分类

全部博文(112)

文章存档

2011年(19)

2010年(54)

2009年(39)

分类: LINUX

2010-02-12 11:26:58

删除指定目录下重复文件
简介:
工具:fdupes ,它会查找和删除指定目录下的重复文件,它通过文件的大小和MD5值进行比较 。
How do I find duplicate files in a given set of directories and delete them using a shell script or a command line options? How do I get rid of double duplicates files stored in ~/foo and /u2/foo directory?

You need to use a tool called fdupes. It will searche the given path for duplicate files. Such files are found by comparing file sizes and MD5 signatures, followed by a byte-by-byte comparison. fdupes is a nice tool to get rid of duplicate files.

Install fdupes

Type the following command under Debian / Ubuntu Linux:

Type the following command under Redhat / RHEL / Fedota / CentOS Linux, enter (turn on before running the following ):
# yum install fdupes

How Do I Use fdupes?

Find duplicate files in /etc/ directory, enter:
# fdupes /etc
Sample outputs:

/etc/vimrc
/etc/virc

How Do I Delete Unwanted Files?

You can force fdupes to prompt you for files to preserve, deleting all others (use this with care otherwise you may loss data): # fdupes -d /etc
Sample outputs:

[1] /etc/vimrc
[2] /etc/virc

Set 1 of 1, preserve files [1 - 2, all]: 1

   [+] /etc/vimrc
   [-] /etc/virc

How Do Recursively Search Directory?

You can recursively search every directory given follow subdirectories encountered within the -r option, enter:
# fdupes -r /dir1

How Do I Find Dupes In Two Directories?

Type the command as follows:
# fdupes /dir1 /dir2
OR
# fdupes -r /etc /data/etc /nas95/etc

How Do I See Size Of Duplicate Files?

Type the following command with the -S option:
# fdupes -S /etc
Sample outputs:

1533 bytes each:
/etc/vimrc
/etc/virc
原文出处:
转载有理,分享无罪
阅读(1069) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~