在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.mzph.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…