检查终端中的重复项? [英] Checking duplicates in terminal?

查看:37
本文介绍了检查终端中的重复项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码向我打印了一长串带有哈希值和文件名的文件

The following code prints me a long list of files with hashes and file names

md5sum *.java

我曾尝试列出出现相同哈希值的行,但未成功,因此我可以删除相同的文件.

I have tried unsuccessfully to list the lines where identical hashes occur, so that I can then remove identical files.

如何过滤和删除内容相同的相同文件?

How can you filter and delete identical files which have same content?

推荐答案

fdupes 并减少对重复项的查看

使用 fdupes 这是一个命令行程序,例如

fdupes and less view on duplicates

Use fdupes which is a commandline program such as

fdupes -r /home/masi/Documents/ > /tmp/1 
less -M +Gg /tmp/1

查找所有重复项并将它们存储在临时文件中.less 命令向您显示所有行的行位置以及您的进度百分比.我从这个 answer 及其清晰的维基百科文章 此处.您可以在 OSX 中通过 homebrew 安装它,在 Linux 中通过 apt-get 安装它.

which finds all duplicates and stores them in file in temp. The less command shows you the line position of all lines and your proceeding as percentage. I found fdupes from this answer and its clear Wikipedia article here. You can install it by homebrew in OSX and by apt-get in Linux.

运行

fdupes -rd /home/masi/Documents

让您选择要删除或不删除的副本,交互式作品的示例视图:

which let's you choose which copy to delete or not, example view of the interactive work:

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

   [+] /home/masi/Documents/Exercise 10 - 1.4.2015/task.bib
   [+] /home/masi/Documents/Exercise 9 - 16.3.2015/task.bib

[1] /home/masi/Documents/Celiac_disease/jcom_jun02_celiac.pdf
[2] /home/masi/Documents/turnerWhite/jcom_jun02_celiac.pdf

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

   [-] /home/masi/Documents/Celiac_disease/jcom_jun02_celiac.pdf
   [+] /home/masi/Documents/turnerWhite/jcom_jun02_celiac.pdf

你看到我有 2664 个重复.如果有一些静态文件可以保存有关我想要的重复项的设置,那就太好了;我在此处打开了一个主题帖.例如,我在一些练习和家庭作业中有相同的围兜文件,所以当用户想要重复时不要第二次询问.

where you see that I have 2664 duplicates. It would be nice to have some static file which would save the settings about my wanted duplicates; I opened a thread about this here. For instance, I have same bib -files in some exercises and homework so do not ask second time when the user wants the duplicate.

这篇关于检查终端中的重复项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆