日期:2014-05-16  浏览次数:20563 次

find命令找出指定文件
1、用find . -size 100 -print可以打印出100blocks大小的文件。
但是用后显示的其中一个文件,用ls看大小是:474,这个是字节?还是100*512(1个block=512bytes)?

2、用find . -size 100 -exec rm -f {}\;或find . -size 100 | xargs rm -f;为什么无法删除呢?

3、是用find . -name "*" -type f -size -2024k -print和find . -name "*" -type f -size -2024c -print展示的文件不同,前者只返回一个文件,后者返回几十个文件。k表示占用空间大小是2k,c表示文件大小是2k,但-k占用空间为2k,我看也是中间时间段的一些文件,没有规律的?

4、find . -name "*" -type f -size -1024000c -print | wc -l 返回5个。
find . -name "*" -type f -size +1M -print | wc -l 返回10个。
1024000c应该等于1M,但如果用c这里表示文件大小,如果用M表示占用空间?那+1M除文件自身大小还有其它大小?

谢谢!

------解决方案--------------------
+num 表示大于num字节的文件
-num 表示小于num字节的文件
num  表示等于num字节的文件


删不掉是否是由于权限问题?
------解决方案--------------------
这么多的问题都是关于-size这个参数的。还是仔细阅读关于size部分的man吧。
引用
       -size n[cwbkMG]
              File uses n units of space.  The following suffixes can be used:

              `b'    for 512-byte blocks (this is the default if no suffix is used)

              `c'    for bytes

              `w'    for two-byte words

              `k'    for Kilobytes (units of 1024 bytes)

              `M'    for Megabytes (units of 1048576 bytes)

              `G'    for Gigabytes (units of 1073741824 bytes)

              The  size  does not count indirect blocks, but it does count blocks in sparse files that are not actually allocated.
              Bear in mind that the `%k' and `%b' format specifiers of -printf handle sparse files differently.   The  `b'  suffix
              always denotes 512-byte blocks and never 1 Kilobyte blocks, which is different to the behaviour of -ls.