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

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?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參數將返回以兆字節為單位的列表(請注意,您可以使用-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    Files1
993     Files2
38      Somefile.txt

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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278472.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278472.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278472.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

記一次kafka數據丟失問題的排查

2019獨角獸企業重金招聘Python工程師標準>>> 數據丟失為大事,針對數據丟失的問題我們排查結果如下。 第一:是否存在數據丟失的問題? 存在,且已重現。 第二:是在什么地方丟失的數據,是否是YDB…

Maximum upload size exceede上傳文件大小超出解決

在這里記錄三種方法, 努力提高自己的姿勢水平 application.yml配置spring:servlet:multipart:enabled: truemax-file-size: 10MB #單個文件最大大小max-request-size: 1024MB #上傳數據總大小 application.properties配置spring.servlet.multipart.max-file-size10Mb #單個文件…

ipad iphone開發_如何在iPhone或iPad上更改應用程序的語言

ipad iphone開發BigTunaOnline/Shutterstock.comBigTunaOnline / Shutterstock.comApple’s iOS 13 makes the iPhone and iPad multilingual. Now, you can change the language of an individual app without changing your primary system language. Each app can have its …

Docker最全教程——從理論到實戰(七)

Docker最全教程——從理論到實戰(七) 原文:Docker最全教程——從理論到實戰(七)在本系列教程中,筆者希望將必要的知識點圍繞理論、流程(工作流程)、方法、實踐來進行講解,而不是單純…

Bash Cookbook 學習筆記 【中級】

Read Me 本文是以英文版<bash cookbook> 為基礎整理的筆記&#xff0c;力求脫水2018.01.21 更新完【中級】。內容包括工具、函數、中斷及時間處理等進階主題。本系列其他兩篇&#xff0c;與之互為參考 【基礎】內容涵蓋bash語法等知識點。傳送門【高級】內容涉及腳本安全…

設置Windows 10時如何創建本地帳戶

Windows 10 tries its hardest to make you use a Microsoft account. The option was already hidden, but now it’s not even offered on Windows 10 Home while you’re connected to the internet. Here’s how to create a local account anyway. Windows 10盡最大努力使…

HSQL

Hive的數據存儲  1、Hive中所有的數據都存儲在 HDFS 中&#xff0c;沒有專門的數據存儲格式&#xff08;可支持Text&#xff0c;SequenceFile&#xff0c;ParquetFile&#xff0c;RCFILE等&#xff09;  2、只需要在創建表的時候告訴 Hive 數據中的列分隔符和行分隔符&…

在PowerPoint 2010中將鼠標用作激光筆

Have you ever wished you had a laser pointer to focus attention on a key point in a PowerPoint slideshow? Today, we’ll take a look at how can use use your mouse as a laser pointer in PowerPoint 2010. 您是否曾經希望激光指示器能將注意力集中在PowerPoint幻燈…

Java 8 并發: 原子變量和 ConcurrentMap

原文地址: Java 8 Concurrency Tutorial: Atomic Variables and ConcurrentMap AtomicInteger java.concurrent.atomic 包下有很多原子操作的類。 在有些情況下&#xff0c;原子操作可以在不使用 synchronized 關鍵字和鎖的情況下解決多線程安全問題。 在內部&#xff0c;原子類…

this表示當前對象簡單實例

直接上代碼 class Message { private Channel channel ; // 保存消息發送通道 private String title ; // 消息標題 private String content ; // 消息內容 // 4、調用此構造實例化&#xff0c;此時的channel 主類ch public Message(Channel channel,String title,String cont…

twitter推文不收錄_如何使用Twitter書簽保存推文供以后使用

twitter推文不收錄Khamosh PathakKhamosh PathakTwitter has a new Bookmarks feature that lets you privately save tweets for later. If you’ve been using the Like feature as a workaround for saving tweets, here’s why you should start bookmarking. Twitter具有一…

if的作用域問題 *輸出1~6的隨機數*

1 //測試if語句2 public class TestIf {3 public static void main(String[] args){4 double d Math.random();//0~1之間的小數5 int e (int)(d*5); //[0,4]6 //int f 1(int)(d*6); //[1,6] 擲色子7 System.out.println(e);8 …

為您的Blogger博客設計一個美麗的新主題

Would you like to give your Blogger blog a fresh coat of paint with a new theme? Here’s how you can use the new Template Designer to make your Blogger site stand out from the crowd and look great. 您想給Blogger博客一個新的主題嗎&#xff1f; 您可以通過以…

Lab 6-4

In this lab, we’ll analyze the malware found in the file Lab06-04.exe. Questions and Short Answers What is the difference between the calls made from the main method in Labs 6-3 and 6-4? A: The function at 0x401000 is the check Internet connection method…

步入三十歲前的總結:看似經歷很多得到很多,但,實際卻一無所得

本文算是一篇審視自己的文章吧&#xff0c;感覺跟我類似經歷的人應該很多&#xff0c;認同感應該也大一些。我是12年網絡專業很普通的一所大專院校畢業&#xff0c;到現在為止工作已經超過五年。這五年里&#xff0c;做過運維工程師&#xff0c;也在小車床工作間里做了一下技工…

vue---day03

1. Vue的生命周期 - 創建和銷毀的時候可以做一些我們自己的事情 - beforeCreated - created - beforeMount - mounted - beforeUpdate - updated - activated - deactivated - beforeDestroy - destroyed 1.1 知識點回顧 1.1.1 be…

U Sparkle 開發者計劃招募中!

向我們投稿吧 在此之前&#xff0c;我們有收到過幾篇民間高手的投稿&#xff0c;如&#xff1a; USequencer 初識&#xff08;作者&#xff1a;焱燚(七火)&#xff09; Unity游戲界面解決方案: PSD For UGUI&#xff08;作者&#xff1a;張俊欽&#xff09; UGUI 降低填充率技巧…

階乘和 大整數

///大整數階乘的和 #include<bits/stdc.h> using namespace std; int main() {int n;while(cin>>n){int a[2000] {1},b[2000] {0}; //存放結果的數組a。int c; //b用于存放每位存放的結果。int r0; //r用來表示進位的數。int h1,hb1; //h用來表示運算過程中 結果a…

如何添加引文標_如何在Google文檔中查找和添加引文

如何添加引文標When writing papers, you need to generate a detailed and accurate list of all the sources you’ve cited in your paper. With Google Docs, you can easily find and then add citations to all of your research papers. 撰寫論文時&#xff0c;您需要生…

mongo ttl索引

db.log_events.find() # 查找log_events里的所有數據db.log_events.createIndex( { "LogDT": 1 }, { expireAfterSeconds: 3600 } ) #設置log_events里的TTL過期索引清理時間為3600秒db.runComman…