博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在Linux上按大小列出文件和目录
阅读量:2514 次
发布时间:2019-05-11

本文共 1078 字,大约阅读时间需要 3 分钟。

This page will show us how to create a list of files and folders ordered by size using standard Linux commands.

该页面将向我们展示如何使用标准Linux命令创建按大小排序的文件和文件夹列表。

命令 (Command)

To get a list with the size of each item in a folder, you’ll want to use the  command like this:

要获得一个文件夹中每个项目的大小的列表,您将需要使用命令,如下所示:

du -sm *

The -m argument will return the listing in megabytes (note that you can use -h for human readable, but it won’t sort correctly)

-m参数将返回以兆字节为单位的列表(请注意,您可以使用-h使其易于阅读,但无法正确排序)

Now we will want to run this through the sort command, sorting in reverse order -r and numeric -n:

现在,我们将要通过sort命令运行此命令,以相反的顺序-r和数字-n进行排序:

du -sm * | sort -nr

The only problem here is that we’ll get way too much output if there are a lot of files and folders, so we can either pipe it through the more command:

唯一的问题是,如果文件和文件夹很多,我们将获得过多的输出,因此我们可以通过more命令将其传递给管道:

du -sm * | sort -nr | more

Or we can just return the top 15 largest items:

或者,我们可以返回前15个最大的项目:

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

This will return a listing something like this:

这将返回如下列表:

2907    Files1993     Files238      Somefile.txt

翻译自:

转载地址:http://ehvwd.baihongyu.com/

你可能感兴趣的文章
[MTK FP]用Python把图片资源image.rar中为.pbm后缀的文件更改为.bmp后缀的方法
查看>>
实验二
查看>>
[LeetCode]203. Remove Linked List Elements 解题小结
查看>>
测试一下
查看>>
vue base64
查看>>
【Django实战开发】案例一:创建自己的blog站点-1.安装及搭建开发环境
查看>>
Pie(二分)
查看>>
Mysql 索引优化
查看>>
09湖州二模(自选模块不等式)
查看>>
Mybatis Batch 批量操作
查看>>
Ubuntu server搭建Java web服务器
查看>>
WSGI学习系列WSME
查看>>
java读取xml配置文件和properties配置文件
查看>>
HDU 4300 Contest 1
查看>>
POJ 3311
查看>>
Button MouseEvent颜色变化
查看>>
Volist标签
查看>>
浅谈模块化
查看>>
14个免费访客行为分析工具
查看>>
beego orm关联查询之多对多(m2m)
查看>>