0

I've seen questions about how I can remove all files under a certain file size, but none of them have dealt with very small files (most of mine are simple .txt files that contain 500-1200 characters). All of the solutions I've seen so far look something like

find . -size -1k -delete

I've tried using the following:

find . -size -600
find . -size -600b
find . -size -0.6k

None of which worked, can someone tell me how to make this method work for smaller file sizes? (I'm sure I'm just missing a trailing character after the 600)

4

2 回答 2

5

c是字节的大小说明符,表示字符。b您可能认为可行的变体实际上适用于块(每个 512 字节)。

这一切都包含在手册页中的详细信息find

-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)
于 2013-05-15T08:50:43.993 回答
1

你应该使用

find . -size -600c

对于字节

于 2013-05-15T08:50:56.173 回答