加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Bash – 如何找到目录及其子目录中最大的文件?

发布时间:2020-12-15 16:38:58 所属栏目:安全 来源:网络整理
导读:我们只是开始一个UNIX类,并正在学习各种Bash命令。我们的任务涉及在一个目录下执行各种命令,该目录下也有很多文件夹。 我知道如何列出和计数从根文件夹中的所有常规文件使用: find . -type l | wc -l 但我想知道从哪里去,以找到在整个目录中最大的文件。
我们只是开始一个UNIX类,并正在学习各种Bash命令。我们的任务涉及在一个目录下执行各种命令,该目录下也有很多文件夹。

我知道如何列出和计数从根文件夹中的所有常规文件使用:

find . -type l | wc -l

但我想知道从哪里去,以找到在整个目录中最大的文件。我看过有关du命令的一些事,但我们还没有学到,所以在我们学到的东西的一切,我认为我们需要以某种方式连接到ls -t命令。

如果我的“lingo”不正??确,请原谅我,我仍然习惯了它!

报价从 this link-

If you want to find and print the top 10 largest files names (not
directories) in a particular directory and its sub directories

$ find . -printf '%s %pn'|sort -nr|head

To restrict the search to the present directory use “-maxdepth 1” with
find.

$ find . -maxdepth 1 -printf '%s %pn'|sort -nr|head

And to print the top 10 largest “files and directories”:

$ du -a . | sort -nr | head

** Use “head -n X” instead of the only “head” above to print the top X largest files (in all the above examples)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读