Linux命令,如何通过大于x的大小查找文件?

时间:2023-01-15 10:22:59

I'm trying to find files with size larger than "x" , ex: 32 bytes

我正在尝试查找大小大于“x”的文件,例如:32字节

But what I found in ls --help was only ls -S , that just sort by size and not satisfied my demand

但我在ls --help中找到的只是ls -S,只是按大小排序而不满足我的要求

I'm new to Linux , I've tried Google but I don't know what keywords should I use to find answer , could somebody give me advice , thank you !

我是Linux的新手,我已经尝试了Google,但我不知道应该使用哪些关键字来寻找答案,有人可以给我建议,谢谢!

2 个解决方案

#1


5  

Try to use the power of find utility.

尝试使用find实用程序的强大功能。

Find files greater than 32 bytes:

查找大于32字节的文件:

find -size +32c

Of course you could also ask for files smaller than 32 bytes:

当然你也可以要求小于32字节的文件:

find -size -32c

And files with exact 32 bytes:

和精确32字节的文件:

find -size 32c

For files with 32 bytes or more:

对于32字节或更多字节的文件:

find -size 32c -o -size +32c

Or not smaller than 32 bytes (the same as above, but written another way):

或者不小于32个字节(与上面相同,但以另一种方式编写):

find ! -size -32c

And files between 32 and 64 bytes:

和32到64字节之间的文件:

find -size +32c -size -64c

And you can also apply other common suffixes:

您还可以应用其他常见后缀:

find -size +32k -size -64M

#2


3  

Try this:

find . -size +32c -ls

You can change 32 for the size you want. In this case, I used your example.

您可以根据需要更改32。在这种情况下,我使用了你的例子。

#1


5  

Try to use the power of find utility.

尝试使用find实用程序的强大功能。

Find files greater than 32 bytes:

查找大于32字节的文件:

find -size +32c

Of course you could also ask for files smaller than 32 bytes:

当然你也可以要求小于32字节的文件:

find -size -32c

And files with exact 32 bytes:

和精确32字节的文件:

find -size 32c

For files with 32 bytes or more:

对于32字节或更多字节的文件:

find -size 32c -o -size +32c

Or not smaller than 32 bytes (the same as above, but written another way):

或者不小于32个字节(与上面相同,但以另一种方式编写):

find ! -size -32c

And files between 32 and 64 bytes:

和32到64字节之间的文件:

find -size +32c -size -64c

And you can also apply other common suffixes:

您还可以应用其他常见后缀:

find -size +32k -size -64M

#2


3  

Try this:

find . -size +32c -ls

You can change 32 for the size you want. In this case, I used your example.

您可以根据需要更改32。在这种情况下,我使用了你的例子。