Linux查看某目录占用空间以及其下有多少个文件

来源:互联网 发布:西安交大软件学院 编辑:程序博客网 时间:2024/04/29 11:01

原文链接:http://snailwarrior.blog.51cto.com/680306/153562


查看某目录占用空间命令:
# du -sh DirPath
比如: du -sh /home/snail
 
查看某目录下有多少个文件命令:
# find DirPath -type f | wc -l
比如: find /home/snail -type f | wc -l
 
如果想查看 src 目录下有多少 C 文件,如下:
# find ./src -type f -name "*.c" | wc -l
 
find 命令的 -type 后的参数有以下选择,每种都代表不一样的“类型(type)”
-type 文件类型
        b      块文件(比如内存)
        c      字符文件(比如串口)
        d      目录文件(目录也是一种文件)
        p      有名管道(FIFO)
        f      普通文件
        l      符号链接(如果使用 -L 或 -follow 选项则不起作用,除非链接损坏) 
        s      socket文件(比如 /tmp/mysql.sock)
        D      door (Solaris)