列表文件在一个特定的大小当前目录及其所有子目录 [英] List files over a specific size in current directory and all subdirectories

查看:130
本文介绍了列表文件在一个特定的大小当前目录及其所有子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能显示所有文件在我的当前目录下超过10K字节,它的子目录。

How can I display all files greater than 10k bytes in my current directory and it's subdirectories.

尝试 LS -size + 10K ,但没有奏效。

推荐答案

找到。 -size + 10K -exec LS -lh {} \\ +

这第一部分是相同的@sputnicks答案,sucesffully查找所有目录中的文件超过10K(不要混淆K的K),我另外,第二部分,然后执行 LS -lh 或列出LS(-l)由人类可读的尺寸(H)的文件。否定h如果preFER。当然 {} 是文件本身,而 \\ + 是简单地替代 \\

the first part of this is identical to @sputnicks answer, and sucesffully finds all files in the directory over 10k (don't confuse k with K), my addition, the second part then executes ls -lh or ls that lists(-l) the files by human readable size(-h). negate the h if you prefer. of course the {} is the file itself, and the \+ is simply an alternative to \;

在实践 \\ 会重复或:

ls -l命令found.file; ls -l命令found.file.2; ls -l命令found.file.3

其中, \\ + 显示为一个语句或:

where \+ display it as one statement or:

ls -l命令found.file found.file.2 found.file.3

有关 \\;与VS + 找到

Additionaly,您可能希望通过大小排序列表。这是比较容易实现。我将在 -s 选项 LS ,所以 LS -ls ,然后管道它排序-n 来排序数字

Additionaly, you may want the listing ordered by size. Which is relatively easy to accomplish. I would at the -s option to ls, so ls -ls and then pipe it to sort -n to sort numerically

这将变成:

找到。 -size + 10K -exec LS -ls {} \\ + |排序-n

或以相反的顺序添加-r:

or in reverse order add an -r :

找到。 -size + 10K -exec LS -ls {} \\ + |排序-nr

最后,你的标题说,找到的最大目录中的文件。你可以做到这一点,然后通过管道将code到

finally, your title says find biggest file in directory. You can do that by then piping the code to tail

找到。 -size + 10K -exec LS -ls {} \\ + |排序-n |尾-1
会发现你在目录中的最大文件和子目录。

find . -size +10k -exec ls -ls {} \+ | sort -n | tail -1 would find you the largest file in the directory and its sub directories.

请注意,您也可以按大小文件通过使用-S进行排序,并否定了排序的需要。但要找到最大的文件,你将需要使用头部这样

note you could also sort files by size by using -S, and negate the need for sort. but to find the largest file you would need to use head so

找到。 -size + 10K -exec LS -lS {} \\ + |头-1

与-S这样做的好处,而不是排序是一个,你不必键入排序-n 和两个你也可以使用 -h 人类可读的大小选项。这是我最喜欢用的一个,但不可用 LS的较旧的versisions ,比如我们在工作中有一个旧的CentOS 4的服务器不具有 -h

the benefit of doing it with -S and not sort is one, you don't have to type sort -n and two you can also use -h the human readable size option. which is one of my favorite to use, but is not available with older versisions of ls, for example we have an old centOs 4 server at work that doesn't have -h

这篇关于列表文件在一个特定的大小当前目录及其所有子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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