By piping the output to thesort command. And in this tutorial, I will share several examples of how you sort the output by size. How to sort du command output As I mentioned earlier, the du command does not have a built-in functionality to sort output so you'll have to pipe it to ...
[root@ecs-centos-7 tt]# du -ah temp/* | sort -hr | head -n 310M temp/clpay.tar 16K temp/test 8.0K temp/test/ha 通过上面介绍的几种方式可以找出指定目录中哪些文件或目录占用磁盘空间比较大,清理的时候优先清理它们 出处:https://www.cnblogs.com/wanng/p/linux-du-command.html === Linux...
04 常用组合 du + sort + head du -a /temp/logs | sort -nr # 按照文件从大到小排序(含隐藏文件,包含目录,文件,层级目录下文件); du -m --max-depth=1 /temp/logs | sort -nr | head -n 10 # 指定目录第一层,显示前 Top10,-m: 统计单位为MB,为什么不用-h?sort 大小排序只看数字,不看...
du -a /temp/logs | sort -nr # 按照文件从大到小排序(含隐藏文件,包含目录,文件,层级目录下文件); du -m --max-depth=1 /temp/logs | sort -nr | head -n 10 # 指定目录第一层,显示前 Top10,-m: 统计单位为MB,为什么不用-h?sort 大小排序只看数字,不看单位,可能会导致 2G 反而排序在 200...
04 常用组合 du + sort + head du -a /temp/logs | sort -nr # 按照文件从大到小排序(含隐藏文件,包含目录,文件,层级目录下文件); du -m --max-depth=1 /temp/logs | sort -nr | head -n 10 # 指定目录第一层,显示前 Top10,-m: 统计单位为 MB,为什么不用 - h?sort 大小排序只看数字,...
sort命令的基本语法为: “` sort [参数] [文件名] “` 下面是sort命令的一些常用参数: –-r:以降序的方式进行排序。 –-n:按照数值进行排序。 –-f:忽略大小写进行排序。 –-u:去除重复的行。 –-t:指定字段分隔符,默认为制表符。 –-k:指定按照哪个字段排序。
du --max-depth=1 [目录] # 只显示指定目录下第一层目录(不单个含文件)的大小; du --max-depth=2 [目录] # 只显示指定目录第一和二层目录(不含单个文件)的大小; 03 sort 常用参数 (sort 作用是将文件内容排序,以行为单位) -n # 依照数值的大小排序; ...
> du -c a.log b.log 4 a.log 0 b.log 4 total 加上-c选项后,du不仅显示两个目录各自占用磁盘空间的大小,还在最后一行统计它们的总和。 按照空间大小排序 > du -ah src | sort -nr 108K ./src 108K . 52K ./src/one 48K ./src/one/etc.tar.gz 12K ./src/nohup.out 12K ./src/bin/ru...
sort data.txt | uniq 这将删除排序后 data.txt 中的任何重复行。uniq可让你控制重复文本的过滤。 16.diff– 逐行比较文件 diff命令逐行比较两个文件并打印差异。它通常用于显示文件版本之间的变化。语法 语法: diff [options] file1 file2 选项:
du和sort命令的使用 1|0du 命令: du [选项][文件] du命令用来查看目录或文件所占用磁盘空间的大小。常用选项组合为:du -sh 一、du的功能: 很明显,与df不同,它用来查看文件或目录所占用的磁盘空间的大小。 二、du常用的选项: -h:以人类可读的方式显示 ...