文件/目录操作(4)——file、stat、du命令

 file命令

        file   file1   file2  

        file    -b             //查看文件类型

        file    -f              //读出文本文件中每一行的文件,并判别文件类型【脚本中查看文件类型】
[root@localhost shell]# file test.txt 
test.txt: ASCII text
[root@localhost shell]# file -b test.txt 
ASCII text

[root@vm_hosts ~]# cat file.txt 
/etc/passwd
string just a test txt
[root@vm_hosts ~]# file -f file.txt 
/etc/passwd:            ASCII text
string just a test txt: cannot open `string just a test txt' (No such file or directory)

stat命令
         显示对象的详细信息(状态)        
[root@localhost lyj]# stat .
  File: "."
  Size: 4096      	Blocks: 8          IO Block: 4096   目录
Device: fd00h/64768d	Inode: 1572865     Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-10-13 03:14:08.797401158 +0800
Modify: 2015-10-08 03:32:55.600587141 +0800
Change: 2015-10-08 03:32:55.600587141 +0800
注意这三个“时间”的不同:   
          Access:上一次访问时间。
          Modify:上一次修改时间——指“内容的修改”。
          Change:上一次状态/属性修改时间——指“属性(如权限、大小等的修改)”。
         
        stat   -f  显示有关文件系统(而非文件)的信息
        stat   -t  以一行的格式显示信息【在shell脚本中有用!】
[root@localhost lyj]# stat -f .
  File: "."
    ID: ad73353be9b38fb8 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 12901535   Free: 7968969    Available: 7313609
Inodes: Total: 3276800    Free: 3151282
[root@localhost lyj]# stat -t  .
. 4096 8 41ed 0 0 fd00 1572865 3 0 0 1444677248 1444246375 1444246375 4096

       
du命令  
      du  file1 file2   显示指定文件/目录的大小      
      -s                       显示当前目录的大小(而不包括显示子目录)
      -h                       以K、M、G这样易读的单位显示
      -c                       显示大小并最后计算count总和大小
      du  | sort  -nr    按文件大小排序
      du  -h   --max-depth=1   输出当前目录下各个子目录的大小 
[root@localhost ~]# du  -sh /etc/passwd
4.0K	/etc/passwd

[root@localhost ~]# du -h --max-depth=1   /etc
28K	/etc/rpm
52K	/etc/udev
20K	/etc/audisp
20K	/etc/ConsoleKit
4.0K	/etc/thnuclnt
72K	/etc/init
40K	/etc/logrotate.d

        
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值