我试过这个:
find . -type f -size 128 -exec mv {} new_dir/ \;
Run Code Online (Sandbox Code Playgroud)
哪个不起作用,它没有给我一个错误。这是使用时文件外观的示例stat -x
$ stat -x ./testfile | grep Size
Size: 128 FileType: Regular File
Run Code Online (Sandbox Code Playgroud)
从我的联机帮助页(在 MacOS 10.11 机器上)
-size n[ckMGTP]
True if the file's size, rounded up, in 512-byte blocks is n. If
n is followed by a c, then the primary is true if the file's size
is n bytes (characters). Similarly if n is followed by a scale
indicator then the file's size is compared to n scaled as:
k kilobytes (1024 bytes)
M megabytes (1024 kilobytes)
G gigabytes (1024 megabytes)
T terabytes (1024 gigabytes)
P petabytes (1024 terabytes)
Run Code Online (Sandbox Code Playgroud)
(c
非标准扩展以外的后缀)。
因此,由于您没有指定后缀,您的-size 128
意思是 128 blocks或 64Kbytes 仅与大小介于 127*512+1 (65025) 和 128*512 (65536) 字节之间的文件匹配。
-size 128c
如果您想要恰好 128 字节-size -128c
的文件、大小严格小于 128 字节(0 到 127)-size +128c
的文件以及大小严格大于 128 字节(129 字节及以上)的文件,则应使用。