linux centos查找文件夹,根据文件大小查找文件的find命令举例(Linux,centos,redhat)

用法:find [路径...] [表达式]

find [-H] [-L] [-P] [path...] [expression]

default path is the current directory; default expression is -printexpression may consist of: operators, options, tests, and actions:

operators (decreasing precedence; -and is implicit where no others are given):

( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2

EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2

positional options (always true): -daystart -follow -regextype

normal options (always true, specified before other expressions):

-depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf

--version -xdev -ignore_readdir_race -noignore_readdir_race

tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N

-cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME

-ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN

-links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE

-nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN

-wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N

-used N -user NAME -xtype [bcdpfls]

-context CONTEXT

actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print

-fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit

-exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;

-execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;

根据文件大小查找文件的find命令举例

linux下的find命令用来查找文件,通过man find就知道它是无所不能的。所以按照文件大小来查找文件就不在话下。从man find搜索size,可以看到如下信息:

-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)

注意:默认单位是b,而它代表的是512字节,所以2表示1K,1M则是2048,如果不想自己转换,可以使用其他单位,如c、K、M等。

find例子:

查找当前目录下文件大小为2048(2k)字节的文件

find ./ -size 4

find ./ -size 2048c

find ./ -size 2K

上述查找文件是等于指定大小的,那能不能查询大于或小于某个指定值的文件呢,答案是肯定,例如:

查找大于2K的文件,+ 表示大于

find ./ -size +2048c

查找小于2K的文件,- 表示小于

find ./ -size +2048c -type f

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值