原帖地址:https://www.cnblogs.com/iyoume2008/p/6105590.html

今天正好碰到这样的问题,在博客园中看到有以上地址的一篇文章,照着上面的操作解决了问题,但是排版上看着不是特别舒服,自己也想记录下来,就全文COPY了,只是改了下版式。望作者谅解

如何查找大文件

其实很多时候,你需要了解 /u01/app/oracle/oradata/prod/ 下有哪些大的数据文件,比如文件大小超过100M或1G(阀值视具体情况而定)。那么如何把这些大文件搜索出来呢?

1.1搜索指定目录下超过指定大小的文件

例如我要搜索 /u01/app/oracle/oradata/prod/ 下,超过500M大小的文件

[oracle@Oracle11g ~]$ find /u01/app/oracle/oradata/prod/  -type f -size +500M

/u01/app/oracle/oradata/prod/sysaux01.dbf

/u01/app/oracle/oradata/prod/system01.dbf

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

1.2搜索指定目录下超过指定大小的文件(显示文件用户、属组)

[oracle@Oracle11g ~]$ find /u01/app/oracle/oradata/prod/  -type f -size +500M  -print0 | xargs - ls –l

-rw-r-----  oracle oinstall  - : /u01/app/oracle/oradata/prod/sysaux01.dbf

-rw-r-----  oracle oinstall  - : /u01/app/oracle/oradata/prod/system01.dbf

1.3搜索指定目录下超过指定大小的文件(显示文件详细size)

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

[oracle@Oracle11g ~]$ find /u01/app/oracle/oradata/prod/ -type f -size +500M  -print0 | xargs - du –h

521M    /u01/app/oracle/oradata/prod/sysaux01.dbf

711M    /u01/app/oracle/oradata/prod/system01.dbf

1.4搜索指定目录下超过指定大小的文件(按大小排序,结果有出入)

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

[oracle@Oracle11g ~]$ find /u01/app/oracle/oradata/prod/  -type f -size +500M  -print0 | xargs - du -h | sort -nr

711M    /u01/app/oracle/oradata/prod/system01.dbf

521M    /u01/app/oracle/oradata/prod/sysaux01.dbf

1.5搜索指定目录下超过指定大小的文件(按大小排序,严格的)

不过如上截图所示,有时候排列的顺序并不完全是按大小一致,这个是因为du命令的参数h所致,你可以统一使用使用MB来显示,这样就能解决这个问题

[oracle@Oracle11g ~]$ find /u01/app/oracle/oradata/prod/ -type f -size +500M -print0 | xargs - du -hm | sort –n

     /u01/app/oracle/oradata/prod/sysaux01.dbf

     /u01/app/oracle/oradata/prod/system01.dbf

1.6 搜索指定目录下超过指定大小的文件(详细显示文件的属主、属组、文件大小(M为单位))

[oracle@Oracle11g ~]$ find /u01/app/oracle/oradata/prod/  -type f -size +500M  -print0 | xargs - ls -lh  | sort -nr

rw-r-----  oracle oinstall 711M - : /u01/app/oracle/oradata/prod/system01.dbf
-rw-r----- oracle oinstall 521M - : /u01/app/oracle/oradata/prod/sysaux01.dbf

如何查找Linux下的大目录

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

2.1查找指定目录下的大目录

[oracle@Oracle11g ~]$ du -h /u01  --max-depth=

.7G    /u01/app

16K     /u01/lost+found

.7G    /u01

[oracle@Oracle11g ~]$ du -h /u01  --max-depth=

2.6M    /u01/app/oraInventory

.7G    /u01/app/oracle

.7G    /u01/app

16K     /u01/lost+found

.7G    /u01

[oracle@Oracle11g ~]$ du -h /u01  --max-depth=

16K     /u01/app/oraInventory/ContentsXML

.0K    /u01/app/oraInventory/oui

2.6M    /u01/app/oraInventory/logs

2.6M    /u01/app/oraInventory

.7G    /u01/app/oracle/oradata

.0K    /u01/app/oracle/checkpoints

.0G    /u01/app/oracle/product

716K    /u01/app/oracle/admin

232K    /u01/app/oracle/cfgtoollogs

6.8M    /u01/app/oracle/diag

.7G    /u01/app/oracle

.7G    /u01/app

16K     /u01/lost+found

.7G    /u01

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

[oracle@Oracle11g ~]$ du -h /u01  --max-depth= |sort -n

2.6M    /u01/app/oraInventory

.7G    /u01

.7G    /u01/app

.7G    /u01/app/oracle

16K     /u01/lost+found

[oracle@Oracle11g ~]$ du -h /u01  --max-depth= |sort -n

.7G    /u01/app/oracle/oradata

2.6M    /u01/app/oraInventory

2.6M    /u01/app/oraInventory/logs

.0G    /u01/app/oracle/product

.0K    /u01/app/oracle/checkpoints

.7G    /u01

.7G    /u01/app

.7G    /u01/app/oracle

6.8M    /u01/app/oracle/diag

.0K    /u01/app/oraInventory/oui

16K     /u01/app/oraInventory/ContentsXML

16K     /u01/lost+found

232K    /u01/app/oracle/cfgtoollogs

716K    /u01/app/oracle/admin

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

[oracle@Oracle11g ~]$ du -hm /u01/app/oracle/ --max-depth= | sort -nr | head -

    /u01/app/oracle/

    /u01/app/oracle/product/11.2.

    /u01/app/oracle/product

    /u01/app/oracle/oradata/prod

    /u01/app/oracle/oradata

3.自己整理的(实用的)

3.1 查找系统中的大目录(从大到小排序,取前5个)

[root@Oracle11g ~]# du -hm / --max-depth= | sort -nr | head -

    /
/u01
/usr
/dev
/lib

3.2 查找上面目录(/u01)中的大文件

[root@Oracle11g ~]#  find /u01/app/oracle/  -type f -size +500M  -print0 | xargs - ls -lh  | sort -nr

-rw-r-----  oracle oinstall 711M - : /u01/app/oracle/oradata/prod/system01.dbf
-rw-r----- oracle oinstall 521M - : /u01/app/oracle/oradata/prod/sysaux01.dbf

LINUX下查找大文件及大的文件夹的更多相关文章

  1. linux下使用split 来分割大文件

    linux下使用split 来分割大文件 2010-07-27 15:46:27|  分类: 技术文稿 |  标签:split  分割  linux   |字号 订阅   平常都是使用ssh来进行远程 ...

  2. linux下查找某个目录下包含某个字符串的文件

    有时候要找一些字符串,但是又不知道在哪个文件,只记得一些字符串 那么如何在linux下寻找包含某段文字的文件呢? 强大的find命令可以帮你完成不可能的任务. 比如我只记得我的程序里包含唯一的字符串“ ...

  3. Linux下查找包含BOM头的文件和清除BOM头命令 2014-08-16 12:30:50

    Linux下查找包含BOM头的文件和清除BOM头命令 2014-08-16 12:30:50 分类: 系统运维 查找包含BOM头的文件,命令如下: 点击(此处)折叠或打开 grep -r -I -l ...

  4. linux下查找文件

    1,find 经常在linux下工作,总要查找一些文件,于是就搜索的学习了一下 find 指定目录 指定条件 指定动作 举例:find . -name "my*" 查找 当前目录下 ...

  5. linux下查找指定后缀的文件

    1.linux下查找指定后缀的文件 例如查找当前目录下的所有后缀名时.c或.h的文件 find  .  -type f -regex  ".*\.\(c\|h\)"

  6. 在Linux下查找文件内容包含某个特定字符串的文件

    如何在Linux下查找文件内容包含某个特定字符串的文件? 我的目录下面有test1和test2两个文件夹,里面都含有很多文件,其中test2里面还包含一个test文件夹 我想请问的是,如何通过查找关键 ...

  7. linux下查找文件中空行的行号

    linux下查找文件中空行的行号 linux下查找文件中空行的行号 以aa.txt举例: 方法1:sed -n '/[a-zA-Z0-9@#$%^&*]/!=' aa.txt 方法2:grep ...

  8. [转帖]linux下查找文件及查找包含指定内容的文件常用命令。

    linux下查找文件及查找包含指定内容的文件常用命令. https://blog.csdn.net/yangyu19910407/article/details/18266821 最简单的查找 fin ...

  9. Linux 下三种提高工作效率的文件处理技巧

    Linux 下三种提高工作效率的文件处理技巧 在 Linux 下工作,打交道最多的就是文件了,毕竟 Linux 下工作一切皆文件嘛.Linux 也为大家提供了多种用于处理文件的命令,合理使用这些命令可 ...

  10. vim linux下查找显示^M并且删除

    linux下 ^M的输入方法是ctrl+v然后再ctrl+m vim下在文件中显示^M:e ++ff=unix % 在文件中删除^M:%s/^M$//g 在linux下查找^Mfind ./ | xa ...

随机推荐

  1. jmeter报告分析工具

    一直以来做性能测试都是用jmeter和LR,当然还有一些自己写测试脚本,LR不用说,分析结果那个组件杠杠的!但是jmeter毕竟是开源的,所以分析查看结果不像LR那样自带图形神马的,虽然可以自己写脚本 ...

  2. play框架之模板

    现在网站发展日新月异,网页上显示的东西越来越复杂,看看HTML源码就知道,这东西不是正常人能拼出来的.因此模板应运而生,自我感觉,好的模板应该支持一下功能: 1.支持HTML代码段的复用,即在HTML ...

  3. 分享Nginx在Windows下的管理命令(bat文件)

    话不多说,复制下面的内容,存成bat文件,放到nginx目录下. ====================================================@echo offrem 当前 ...

  4. Zookeeper详解-API(六)

    ZooKeeper有一个绑定Java和C的官方API.Zookeeper社区为大多数语言(.NET,python等)提供非官方API.使用ZooKeeper API,应用程序可以连接,交互,操作数据, ...

  5. 全自动Landsat影像温度反演软件开发

    许久没有更新遥感类软件开发了,都有点生疏了,这一次我带来了一个老的算法,新的东西, 为什么这么说呢,我们知道Landat8.Landsat5等影像,单个影像去做温度反演,并没有什么太大的难度, 但是呢 ...

  6. C# Winfrom 简单的运用Timer控件

    注意,在使用DateAndTime时,需要添加引用 using Microsoft.VisualBasic;否则不可以计算时间之间的差值. using System; using System.Col ...

  7. Java学习笔记——MySQL创建表结构

    一.创建/删除数据库. create database t14; drop database t14; use t14; 二.创建若干表用于测试 这里预留了几个坑,下面要填坑的.. /*创建学生表*/ ...

  8. 前端js倒计时(精确到毫秒)

    话不多说,直接上代码: 有需要直接拿走, <html> <head> <style> div{ width:100%; text-align:center; fon ...

  9. TCP/IP 第四、五章

    1, 2, 整个arp请求的过程. 3,arp -a 获取arp高速缓存.一般arp高速缓存存活时间20分钟,不完整的表项设置为3分钟.因为机器的ip地址可能发生改变. 4, 5,arp一般是操作系统 ...

  10. 分布式全局ID生成方案

    传统的单体架构的时候,我们基本是单库然后业务单表的结构.每个业务表的ID一般我们都是从1增,通过AUTO_INCREMENT=1设置自增起始值,但是在分布式服务架构模式下分库分表的设计,使得多个库或多 ...