日期:2014-05-16 浏览次数:20751 次
stat命令用来显示文件或文件系统的状态。
以下不解释,直接测试。
sh-# mkdir /tmp/test_dir
sh-# ls -ldh /tmp/test_dir/
drwxr-xr-x 2 root root 40 Oct 9 12:24 /tmp/test_dir/
sh-# stat /tmp/test_dir/
File: "/tmp/test_dir/"
Size: 40 Blocks: 0 IO Block: 4096 directory
Device: eh/14d Inode: 2834 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-10-09 12:25:09.000000000
Modify: 2013-10-09 12:24:48.000000000
Change: 2013-10-09 12:24:48.000000000
sh-#
sh-# touch /tmp/test_dir/test_file
sh-# ls -lh /tmp/test_dir/test_file
-rw-r--r-- 1 root root 0 Oct 9 12:26 /tmp/test_dir/test_file
sh-# stat /tmp/test_dir/test_file
File: "/tmp/test_dir/test_file"
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: eh/14d Inode: 4948 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-10-09 12:26:27.000000000
Modify: 2013-10-09 12:26:27.000000000
Change: 2013-10-09 12:26:27.000000000
sh-#
sh-# stat /tmp/test_dir/
File: "/tmp/test_dir/"
Size: 60 Blocks: 0 IO Block: 4096 directory
Device: eh/14d Inode: 2834 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-10-09 12:26:42.000000000
Modify: 2013-10-09 12:26:25.000000000
Change: 2013-10-09 12:26:25.000000000
sh-#
sh-# echo "ooxx" > /tmp/test_dir/test_file
sh-# ls -lh /tmp/test_dir/test_file
-rw-r--r-- 1 root root 5 Oct 9 12:28 /tmp/test_dir/test_file
sh-# stat /tmp/test_dir/test_file
File: "/tmp/test_dir/test_file"
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: eh/14d Inode: 4948 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-10-09 12:26:27.000000000
Modify: 2013-10-09 12:29:39.000000000
Change: 2013-10-09 12:29:39.000000000
sh-#
sh-# stat /tmp/test_dir/
File: "/tmp/test_dir/"
Size: 60 Blocks: 0 IO Block: 4096 directory
Device: eh/14d Inode: 2834 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-10-09 12:26:42.000000000
Modify: 2013-10-09 12:26:25.000000000
Change: 2013-10-09 12:26: