如何找到相同大小的文件? [英] How to find files with same size?
本文介绍了如何找到相同大小的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有像这样的文件结构
a/file1
a/file2
a/file3
a/...
b/file1
b/file2
b/file3
b/...
...
其中每个目录中,有些文件有相同的文件大小,我想删除这些。
where within each dir, some files have the same file size, and I would like to delete those.
我想,如果这个问题可以解决一个目录如DIR A
,然后我可以围绕它包装一个for循环?
I guess if the problem could be solved for one dir e.g. dir a
, then I could wrap a for-loop around it?
for f in *; do
???
done
但我怎么找到相同大小的文件?
But how do I find files with same size?
推荐答案
解决方案以与空格的文件名工作(基于肯特(+1)和awiebe(+1)员额):
Solution working with "file names with spaces" (based on Kent (+1) and awiebe (+1) posts):
for FILE in *; do stat -c"%s/%n" "$FILE"; done | awk -F/ '{if ($1 in a)print $2; else a[$1]=1}' | xargs echo rm
,使其删除重复,删除回声
从xargs的。
这篇关于如何找到相同大小的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文