转自:http://dadoneo.iteye.com/blog/984963

du命令参数详解见:http://baike.baidu.com/view/43913.htm

下面我们只对其做简单介绍;

查看linux文件目录的大小和文件夹包含的文件数


统计总数大小


du -sh filename(其实我们经常用du -sh *,显示当前目录下所有的文件及其大小,如果要排序再在后面加上 | sort -n)

du -sm * | sort -n //统计当前目录大小 并按大小 排序

du -sk * | sort -n

du -sk * | grep filename //查看一个文件夹的大小

du -m | cut -d "/" -f 2 //看第二个/ 字符前的文字

查看此文件夹有多少文件 /*/*/* 有多少文件

du filename/

du filename/*/*/* |wc -l

40752

解释:

wc [-lmw]

参数说明:

-l :多少行

-m:多少字符

-w:多少字

或者也可以打开Nautilus窗口(文件夹首选项),点击“编辑”-“首选项”,切换到“显示”标签,改变“图标标题”下面的树形列表的内容为“大小,修改日期、类型”。设置立即生效。现在在文件图标的下面会显示文件的大小。

PS:

df -hl 查看磁盘剩余空间

du -sm文件
返回该文件夹总M数

更多功能查看:
df --help
du --help

du --help
用法:du [选项]... [文件]...
总结每个<文件>的磁盘用量,目录则取总用量。
长选项必须用的参数在使用短选项时也是必须的。
-a, --all write counts for all files, not just directories
--apparent-size print apparent sizes, rather than disk usage; although
the apparent size is usually smaller, it may be
larger due to holes in (`sparse') files, internal
fragmentation, indirect blocks, and the like
-B, --block-size=SIZE use SIZE-byte blocks
-b, --bytes equivalent to `--apparent-size --block-size=1'
-c, --total produce a grand total
-D, --dereference-args dereference FILEs that are symbolic links
-H like --si, but also evokes a warning; will soon
change to be equivalent to --dereference-args (-D)
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
--si like -h, but use powers of 1000 not 1024
-k like --block-size=1K
-l, --count-links count sizes many times if hard linked
-L, --dereference dereference all symbolic links
-P, --no-dereference don't follow any symbolic links (this is the default)
-0, --null end each output line with 0 byte rather than newline
-S, --separate-dirs do not include size of subdirectories
-s, --summarize display only a total for each argument
-x, --one-file-system skip directories on different filesystems
-X FILE, --exclude-from=FILE Exclude files that match any pattern in FILE.
--exclude=PATTERN Exclude files that match PATTERN.
--max-depth=N print the total for a directory (or file, with --all)
only if it is N or fewer levels below the command
line argument; --max-depth=0 is the same as
--summarize
--help 显示此帮助信息并离开
--version 显示版本信息并离开

eg: du -smh oracle
54G //显示oracle文件夹的大小为54G

unix os下du df简单用法的更多相关文章

  1. du df的用法

    1,两者区别 du,disk usage,是通过搜索文件来计算每个文件的大小然后累加,du能看到的文件只是一些当前存在 的,没有被删除的.他计算的大小就是当前他认为存在的所有文件大小的累加和. df, ...

  2. Cent OS下发送邮件

    首先安装发送邮件的服务: yum install -y sendmail 安装完成之后在安装mutt yum install -y mutt 安装完成之后我们就可以发送邮件了 mutt     tes ...

  3. CATransition(os开发之画面切换) 的简单用法

    CATransition 的简单用法 //引进CATransition 时要添加包“QuartzCore.framework”,然后引进“#import <QuartzCore/QuartzCo ...

  4. slf4j的简单用法以及与log4j的区别

    之前在项目中用的日志记录器都是log4j的日志记录器,可是到了新公司发现都是slf4j,于是想着研究一下slf4j的用法. 注意:每次引入Logger的时候注意引入的jar包,因为有Logger的包太 ...

  5. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  6. Linux学习总结(七)-磁盘管理 du df fdisk

    一 命令df df,即disk free,可用来查看当前系统的挂载情况,也可以用来查看整体磁盘的使用情况df 不带参数,默认以KB单位显示df -i -----查看inodes 使用情况,要清楚理解i ...

  7. 浅谈ViewPager与TabLayout的简单用法

      今天介绍一下ViewPager与TabLayout的简单用法 1.准备   在一切开始之前,你懂得,先导库,老方法,在build.gradle直接添加下面这一句   implementation ...

  8. 【GitHub Desktop】MacOS和Win下配置及简单的使用

    一. GitHub介绍 1.GitHub 是为开发者提供 Git 仓库的托管服务.这是一个让开发者与朋友.同事.同学及陌生人共享代码的完美场所. 总结一下,GitHub 最大的特征是"面向人 ...

  9. UNIX/Linux下C语言的学习路线

    一.工具篇 “公欲善其事,必先利其器”.编程是一门实践性很强的工作,在你以后的学习或工作中,你将常常会与以下工具打交道, 下面列出学习C语言编程常常用到的软件和工具. 1.操作系统    在UNIX或 ...

随机推荐

  1. 使用PL/SQL Developer连接远程DB(本机不安装Oracle客户端)

    本文内容亲测可行环境:    服务端:centos6.7 ,oracle 11g r2 ,动态注册,监听端口号:1521    用户端:win7 ,没有安装ORACLE及其客户端 准备文件:plsql ...

  2. ChatGirl is an AI ChatBot based on TensorFlow Seq2Seq Model

    Introduction [Under developing,it is not working well yet.But you can just train,and run it.] ChatGi ...

  3. salesforce lightning零基础学习(二) lightning 知识简单介绍----lightning事件驱动模型

    看此篇博客前或者后,看一下trailhead可以加深印象以及理解的更好:https://trailhead.salesforce.com/modules/lex_dev_lc_basics 做过cla ...

  4. 你知道src、url、href的全称吗?

    url:Uniform Resource Locator统一资源定位符 src:Source资源 href:Hypertext Reference超文本引用

  5. sqlserver 截取字符串(转)

    SQL Server 中截取字符串常用的函数: 1.LEFT ( character_expression , integer_expression ) 函数说明:LEFT ( '源字符串' , '要 ...

  6. easyui datagrid editor combobox添加空选则清空combobox框

    <script type='text/javascript'> var editIndex = undefined; $(function() { $('#tb1').datagrid({ ...

  7. struts框架从.jsp页面直接访问action

    <%@ page language="java" pageEncoding="UTF-8"%><%String path = request. ...

  8. WPF TextBlock 判断 isTextTrimmed 文本是否超出

    WPF TextBlock 设置TextTrimming情况下 判断 isTextTrimmed(Text 文本是否超出 是否出现了省略号) private bool HasTextTrimmed(T ...

  9. 81. Search in Rotated Sorted Array II (中等)

    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e. ...

  10. textarea不能使用maxlength

    知道文本框有个maxlength属性,有次开发项目中使用了textarea标签,没去看文档,直接加了maxlength属性,且有效果没有报错,喜滋滋的用了,结果没两天就测试出了bug 问题描述:文本域 ...