本文共 1078 字,大约阅读时间需要 3 分钟。
This page will show us how to create a list of files and folders ordered by size using standard Linux commands.
该页面将向我们展示如何使用标准Linux命令创建按大小排序的文件和文件夹列表。
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/