日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

在Linux上按大小列出文件和目录

發(fā)布時間:2023/12/9 linux 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在Linux上按大小列出文件和目录 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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

該頁面將向我們展示如何使用標準Linux命令創(chuàng)建按大小排序的文件和文件夾列表。

命令 (Command)

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

要獲得一個文件夾中每個項目的大小的列表,您將需要使用du命令,如下所示:

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參數(shù)將返回以兆字節(jié)為單位的列表(請注意,您可以使用-h使其易于閱讀,但無法正確排序)

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

現(xiàn)在,我們將要通過sort命令運行此命令,以相反的順序-r和數(shù)字-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 Files1 993 Files2 38 Somefile.txt

翻譯自: https://www.howtogeek.com/168135/list-files-and-directories-by-size-on-linux/

總結(jié)

以上是生活随笔為你收集整理的在Linux上按大小列出文件和目录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。