列出Linux上最大的10个文件或目录

Linux has a rich set of commands for manipulating and accessing files. The du utility gives information on disk usage, and the sort utility can sort the results. Finally, we can run those results through the head command, which gives you the top 10 lines outputted through any other command. We’ll chain the commands together to get the output that we want.

Linux具有一组丰富的用于操作和访问文件的命令。 du实用程序提供有关磁盘使用情况的信息,sort实用程序可以对结果进行排序。 最后,我们可以通过head命令运行这些结果,该命令为您提供通过任何其他命令输出的前10行。 我们将命令链接在一起以获得所需的输出。

First we’ll use the du -sm command to give the results in MB:

首先,我们将使用du -sm命令以MB为单位给出结果:


$ du -sm *

1 wp-config-sample.php

1 wp-config.php

14 wp-content

1 wp-feed.php

—- trimmed —


$ du -sm *

1 wp-config-sample.php

1 wp-config.php

14 wp-content

1 wp-feed.php

—- trimmed —

Now we can see that the results aren’t sorted, so we’ll sort them by the sort -nr command, which sorts by numerical value in reverse. Finally, we’ll run the results through head -10 to get the top 10 results:

现在我们可以看到结果没有排序,因此我们将通过sort -nr命令对其进行排序,该命令将按相反的数值进行排序。 最后,我们将结果从头-10开始进行计算以获得前十个结果:

This is the command we are going to run:

这是我们要运行的命令:


du -sm * | sort -nr | head -10

Here’s an example of the output:

这是输出示例:


$ du -sm * | sort -nr | head -10

14 wp-content

2 wp-includes

1 xmlrpc.php

1 xml.php

1 x.php

1 wp-trackback.php

1 wp-settings.php

1 wp-rss2.php

1 wp-rss.php

1 wp-register.php


$ du -sm * | sort -nr | head -10

14 wp-content

2 wp-includes

1 xmlrpc.php

1 xml.php

1 x.php

1 wp-trackback.php

1 wp-settings.php

1 wp-rss2.php

1 wp-rss.php

1 wp-register.php

Useful stuff.

有用的东西。

via Get the Top 10 Files or Directories on Ubuntu Linux – How-To Geek.

通过获取Ubuntu Linux上的前10个文件或目录– How-To Geek

翻译自: https://www.howtogeek.com/50714/list-the-10-largest-files-or-directories-on-linux/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值