Linux如何查找大文件或目录总结

转载:http://www.cnblogs.com/kerrycode/p/4391859.html

在Windows系统中,我们可以使用TreeSize工具查找一些大文件或文件夹,非常的方便高效,在Linux系统中,如何去搜索一些比较大的文件呢?下面我整理了一下在Linux系统中如何查找大文件或文件夹的方法。

 

1: 如何查找大文件?

其实很多时候,你需要了解当前系统下有哪些大文件,比如文件大小超过100M或1G(阀值视具体情况而定)。那么如何把这些大文件搜索出来呢?例如我要搜索当前目录下,超过800M大小的文件

[root@getlnx01 u03]# pwd
/u03
[root@getlnx01 u03]# find . -type f -size +800M
./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
./oradata/epps/invsubmat_d08.dbf
./oradata/epps/gmtinv_d08.dbf
./oradata/epps/gmtinv_x01.dbf
./oradata/epps/undotbs02.dbf
./oradata/epps/gmtinv_d07.dbf
./oradata/epps/undotbs01.dbf
./oradata/epps/gmtinv_x02.dbf

clip_image001

 

如上命令所示,我们仅仅能看到超过800M大小的文件的文件名称,但是对文件的信息(例如,文件大小、文件属性)一无所知,那么能否更详细显示一些文件属性或信息呢,当然可以,如下所示

[root@getlnx01 u03]# find . -type f -size +800M  -print0 | xargs -0 ls -l
-rw-r----- 1 oracle oinstall 2782846976 Mar  6 11:51 ./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
-rw-r----- 1 oracle oinstall 1878433792 Mar  6 11:53 ./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
-rw-r----- 1 oracle oinstall 1378492416 Mar  6 11:54 ./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
-rw-r----- 1 oracle oinstall 1641381888 Mar  6 11:56 ./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
-rw-r----- 1 oracle oinstall 1564065792 Mar  6 11:58 ./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
-rw-r----- 1 oracle oinstall 1663492096 Mar  6 12:00 ./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
-rw-r----- 1 oracle oinstall 1368244224 Mar  6 12:02 ./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
-rw-r----- 1 oracle oinstall 1629069312 Mar  6 12:04 ./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
-rw-r----- 1 oracle oinstall 1629954048 Mar  6 12:06 ./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
-rw-r----- 1 oracle oinstall 1202192384 Mar  6 12:07 ./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
-rw-r----- 1 oracle oinstall 1189388288 Mar  6 12:10 ./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
-rw-r----- 1 oracle oinstall 1089257472 Mar  6 12:11 ./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
-rw-r----- 1 oracle oinstall 1097687040 Mar  6 12:12 ./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
-rw-r----- 1 oracle oinstall 1051009024 Mar  6 12:13 ./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
-rw-r----- 1 oracle oinstall 4294975488 Apr  3 15:07 ./oradata/epps/gmtinv_d07.dbf
-rw-r----- 1 oracle oinstall 4194312192 Apr  1 22:36 ./oradata/epps/gmtinv_d08.dbf
-rw-r----- 1 oracle oinstall 4294975488 Apr  3 15:54 ./oradata/epps/gmtinv_x01.dbf
-rw-r----- 1 oracle oinstall 4294975488 Apr  3 15:57 ./oradata/epps/gmtinv_x02.dbf
-rw-r----- 1 oracle oinstall 4294975488 Apr  1 22:35 ./oradata/epps/invsubmat_d08.dbf
-rw-r----- 1 oracle oinstall 8589942784 Apr  4 09:55 ./oradata/epps/undotbs01.dbf
-rw-r----- 1 oracle oinstall 8589942784 Apr  4 09:15 ./oradata/epps/undotbs02.dbf

clip_image002

当我们只需要查找超过800M大小文件,并显示查找出来文件的具体大小,可以使用下面命令

[root@getlnx01 u03]# find . -type f -size +800M  -print0 | xargs -0 du -h
1.3G    ./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
1.1G    ./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
1.2G    ./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
1.2G    ./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
1.5G    ./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
1.1G    ./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
1.3G    ./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
1004M   ./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
2.6G    ./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
1.8G    ./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
4.1G    ./oradata/epps/invsubmat_d08.dbf
4.0G    ./oradata/epps/gmtinv_d08.dbf
4.1G    ./oradata/epps/gmtinv_x01.dbf
8.1G    ./oradata/epps/undotbs02.dbf
4.1G    ./oradata/epps/gmtinv_d07.dbf
8.1G    ./oradata/epps/undotbs01.dbf
4.1G    ./oradata/epps/gmtinv_x02.dbf

clip_image003

 

如果你还需要对查找结果按照文件大小做一个排序,那么可以使用下面命令

[root@getlnx01 u03]# find . -type f -size +800M  -print0 | xargs -0 du -h | sort -nr
1004M   ./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
8.1G    ./oradata/epps/undotbs02.dbf
8.1G    ./oradata/epps/undotbs01.dbf
4.1G    ./oradata/epps/invsubmat_d08.dbf
4.1G    ./oradata/epps/gmtinv_x02.dbf
4.1G    ./oradata/epps/gmtinv_x01.dbf
4.1G    ./oradata/epps/gmtinv_d07.dbf
4.0G    ./oradata/epps/gmtinv_d08.dbf
2.6G    ./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
1.8G    ./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
1.6G    ./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
1.5G    ./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
1.3G    ./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
1.3G    ./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
1.2G    ./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
1.2G    ./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
1.1G    ./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
1.1G    ./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1

clip_image004

不过如上截图所示,有时候排列的顺序并不完全是按大小一致,这个是因为du命令的参数h所致,你可以统一使用使用MB来显示,这样就能解决这个问题。到这里,这个在Linux系统查找大文件的命令已经非常完美了,当然如果你还有很多的需求,那么可以在这个命令上做修改、调整.

clip_image005

 

2: 如何查找Linux下的大目录

譬如有时候磁盘空间告警了,而你平时又疏于管理、监控文件的增长,那么我需要快速的了解哪些目录变得比较大,那么此时我们可以借助du命令来帮我们解决这个问题。

[root@getlnx01 u03]# du -h --max-depth=1
16K     ./lost+found
33G     ./flash_recovery_area
37G     ./oradata
70G     .

如果你想知道flash_recovery_area目录下面有哪些大文件夹,那么可以将参数max-depth=2 ,如果你想对搜索出来的结果进行排序,那么可以借助于sort命令。如下所示

[root@getlnx01 u03]# du -h --max-depth=2 | sort -n
3.5G    ./flash_recovery_area/EPPS
16K     ./lost+found
29G     ./flash_recovery_area/backup
33G     ./flash_recovery_area
37G     ./oradata
37G     ./oradata/epps
70G     .
[root@getlnx01 u03]# du -hm --max-depth=2 | sort -n
1       ./lost+found
3527    ./flash_recovery_area/EPPS
29544   ./flash_recovery_area/backup
33070   ./flash_recovery_area
37705   ./oradata
37705   ./oradata/epps
70775   .

clip_image006

[root@getlnx01 u03]# cd /

[root@getlnx01 /]# du -hm --max-depth=2 | sort -n

有时候搜索出来的结果太多了(譬如,我从根目录开始搜索),一直在刷屏,如果我只想查出最大的12个文件夹,怎么办呢?此时就要借助head命令来显示了

[root@getlnx01 /]# du -hm --max-depth=2 | sort -nr | head -12
407480  .
167880  ./u04
158685  ./u02/oradata
158685  ./u02
152118  ./u04/oradata
70775   ./u03
37705   ./u03/oradata
33070   ./u03/flash_recovery_area
5995    ./u01/app
5995    ./u01
3551    ./usr
1558    ./usr/share
[root@getlnx01 /]# 

clip_image007

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541858.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

java编写简单邮件_Javamail,编写简单的程序发送邮件

代码:package com.dai.mail; import java.util.Properties; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.In…

java calendar_Java Calendar getLeastMaximum()方法与示例

java calendarCalendar类的getLeastMaximum()方法 (Calendar Class getLeastMaximum() method) getLeastMaximum() method is available in java.util package. getLeastMaximum()方法在java.util包中可用。 getLeastMaximum() method is used to get the least maximum value …

Shell 标准输入、输出和错误

防伪码:桃花潭水深千尺,不及汪伦送我情。文件描述符(fd):文件描述符是一个非负整数,在打开现存文件或新建文件时,内核会返回一个文件描述符,读写文件也需要使用文件描述符来访问文件…

java需要会的工具_Java开发者必备的几款工具,一定要掌握!

原标题:Java开发者必备的几款工具,一定要掌握!NotepadNotepad是用于编辑xml、脚本以及记笔记的最佳工具。这个工具的最好部分在于,你在Notepad上打开的任何一个文档,在关闭后都会有一个残留文档,它有助于在…

java的equals方法_Java LocalDateTime类| 带示例的equals()方法

java的equals方法LocalDateTime类equals()方法 (LocalDateTime Class equals() method) equals() method is available in java.time package. equals()方法在java.time包中可用。 equals() method is used to check whether this date-time and the given object are equal or…

portlet java_Java Portlet 规范概述

前言1、portlet是一种类似servlet的规范。2、servlet是web组件,portlet也是web组件。参考1、百度百科:portlethttp://baike.baidu.com/link?urlvMzVwpkf5WzOL23GLkgM4C5C7Sarqh1XXShS73L7k-MbGgM0ooZ4Dl2Efor3bb4tZmmLo6v-muG5UW7_CYMTUahttp://hintcnu…

Java LocalDate类| minusWeeks()方法与示例

LocalDate类minusWeeks()方法 (LocalDate Class minusWeeks() method) minusWeeks() method is available in java.time package. minusWeeks()方法在java.time包中可用。 minusWeeks() method is used to subtract the given weeks from this LocalDate and return the LocalD…

Android推荐的几本书

2019独角兽企业重金招聘Python工程师标准>>> 第一阶段 <<第一行代码Android>><<疯狂Android>>第二阶段 <<Android开发艺术探索>><<Android群英传>>Android源码 第三阶段 <<Android开发艺术探索>><&…

java数据类型后缀_java基础知识---基本数据类型

1)四种整数类型(byte、short、int、long)&#xff1a;byte&#xff1a;8 位&#xff0c;用于表示最小数据单位&#xff0c;如文件中数据&#xff0c;-128~127short&#xff1a;16 位&#xff0c;很少用&#xff0c;-32768 ~ 32767int&#xff1a;32 位、最常用&#xff0c;-2^3…

duration java_Java Duration类| minusMillis()方法与示例

duration java持续时间类minusMillis()方法 (Duration Class minusMillis() method) minusMillis() method is available in java.time package. minusMillis()方法在java.time包中可用。 minusMillis() method is used to subtract the given duration in milliseconds from t…

Thread 和 Runnable创建新线程的区别,Runnable可以共享线程类的实例属性

Thread实现多线程&#xff1a; public class Thread2 extends Thread{ public int i; public void run(){ for(; i < 100 ;i) { System.out.println(getName() " " i); } } public static void main(String[] args){ for (int j 0; j < 100; j) { System…

java编程求最小公约数_java求最大公约数与最小公倍数

public class Gongyueshu{public static void main(String[] args){//从控制台输入两个数据int m Integer.parseInt(args[0]);int n Integer.parseInt(args[1]);int y 1 ;int b 1;if (m > 0 && n >0){//先判定这两个数是否为倍数关系&#xff0c;如果是则小数…

tdr上升时间什么设定_TDR的完整形式是什么?

tdr上升时间什么设定TDR&#xff1a;时域反射仪/车票寄存收据/定期存款收据 (TDR: Time Domain Reflectometer/ Ticket Deposit Receipt/ Term Deposit Receipt) 1)TDR&#xff1a;时域反射仪 (1) TDR: Time Domain Reflectometer) TDR is an abbreviation of the "Time D…

【java】反射+poi 导出excel

2019独角兽企业重金招聘Python工程师标准>>> 反射 导出的数组转变成对象 private static Object expexcelMaptobean(Class<?> cobj,Map<String,String> map,int[] expColums,String[] params) throws InstantiationException, IllegalAccessException…

css设置背景图片大小_如何使用CSS设置背景图片大小?

css设置背景图片大小Introduction: 介绍&#xff1a; As we all know that the images are a very responsive yet very creative way to display your web page or website to the users. The images also play a major role in indulging users to websites or web pages. T…

java gc的特性_Java12新特性 -- 可中断的G1 Mixed GC

Java 12 中增强了 G1 垃圾收集器关于混合收集集合的处理策略&#xff0c;这节主要介绍在 Java 12 中同时也对 G1垃圾回收器进行了改进&#xff0c;使其能够在空闲时自动将 Java 堆内存返还给操作系统&#xff0c;这也是 Java 12 中的另外一项重大改进。目前 Java 11 版本中包含…

在Python3中将字符串转换为字节的最佳方法

To convert a string to bytes, there are more than one way, 要将字符串转换为字节&#xff0c;有多种方法&#xff0c; Approach 1: use encode() method 方法1&#xff1a;使用encode()方法 test_str "include_help"print(type(test_str))test_bytes test_st…

【Java】PMD规则学习(1) --字符串比较

PMD是一款采用BSD协议发布的Java程序代码检查工具。该工具可以做到检查Java代码中是否含有未使用的变量、是否含有空的抓取块、是否含有不必要的对象等。该软件功能强大&#xff0c;扫描效率高&#xff0c;是Java程序员debug的好帮手。 PMD支持的编辑器包括&#xff1a;JDevelo…

php定义object数据类型,PHP数据类型(4):对象object

//创建一个类class Student{//定义属性public $name XuGZh;public $age 20;public $sex 男;//定义方法public function getInfo(){//当前对象中访问自己属性用伪变量$thisreturn my name:.$this->name..my age:.$this->age..my sex:.$this->sex;}}对象初始化:要创建…

avr计数_使用8位LCD创建计数器| AVR

avr计数This type of counter may be also used in the EVM machines. A counter can be used to count the number of times a button is pressed. It can have many applications. The most widely used counter application is in EVM and also in customer feedback machin…