Find Out Top Ten Largest Files in Linux
来源:互联网 发布:hd4800玩守望怎么优化 编辑:程序博客网 时间:2024/05/21 06:49
du / -a | sort -nr | head -10
-a : all files, not just directory.
-n: sort by string numeric value.
-r: reverse the order. By default, sort is in the ascending order.
上面的方法会显示目录,实际上我们只关心文件。下面先给出一个错误的例子:
find . -type f -exec ls -lkS {} + | head -10
find的结果集较大时,会出现ls terminated by signal 13的错误。signal 13代表broken pipe。因为head -10读到前10就将管道关闭。我们可以忽略这个错误信息。
根据find的用户手册中-exec 的解释,find命令会产生多个ls进程。这个命令不能保证各个ls进程排序结果也是有序的。
find . -type f | xargs ls -lkS | head -10xargs也有同样问题。
下面给出正确答案:
find -type f -printf "%k %p\n" | sort -nr | headprintf的参数与C语言的printf参数很类似。具体请看find的用户手册。
0 0
- Find Out Top Ten Largest Files in Linux
- Find The Largest Top 10 Files and Directories on Linux
- Linux - Find string in files.
- linux find string in files
- Top Ten Mistakes in Web Design
- Top Ten Mistakes in Web Design
- Top Ten Research Problems in Nonlinear Control
- The Top Ten Algorithms in Data Mining
- Find top 10 large files
- 'find' and 'locate' in linux to look up files
- Top Ten Traps in C# for C++ Programmers中文版(上篇)
- Top Ten Traps in C# for C++ Programmers中文版(下篇)
- Largest Ten Digit Powers
- OpenGL教程 "Top Ten"
- OWSAP Top Ten
- OpenGL教程 "Top Ten"
- top ten vps
- git top ten tips
- 设计模式之 动态代理 - ThreadLocal实现事务管理
- ubuntu无线网卡驱动安装
- extern "c" __declspec(dllexport) __declspec(dllimport)
- Getting Approximate Row Count of a Huge File
- 移动互联网SIP在线状态方案分析
- Find Out Top Ten Largest Files in Linux
- 如何完全卸载oracle
- LeetCode | Valid Sudoku
- __declspec(dllimport)和__declspec(dllexport)的区别,以及有关c/c++调用约定
- Linux Soft Link
- Unable to Find Sources for Current Linux Kernel
- 如何安装MinGW
- Palindrome Number
- Linux开放1521端口允许网络连接Oracle Listener