首页 > 科技 > Linux Shell : find

Linux Shell : find

2005年11月22日 22点55分 发表评论 阅读评论

Find is a very important command, when it is issued, the system resource will be heavily costed,so we’d better put the instance in the background.

find syntax:

#find pathname -options [-print -exec -ok]

pathname: if find file in own HOME directory,the pathname could be instead of ‘~’;if in the current directory,’.’ is used.
-exec : issue the command on the finding result.-exec must be added ‘{} ;’.Please pay attention that there are space between ‘{}’ and ‘;’.
-ok : it works like ‘-exec’,but will require user’s answer before issung the command.
eg:

# find -name '1.txt' -exec rm {} ;
     # find -name '1.txt' -ok rm {} ;

How to find file which is bigger than 1M byte?

# find . -size +1000000c -print

1000000c means 1M byte.Character ‘c’ must be added.

# find . -size +10 -print
'+10' without character 'c' means 10 blocks. 1 block = 512 byte.

If many commands are listed after ‘-exec’, Linux will create instance for every command,it will decrease the Linux performance.We could use xargs,this useful command will create only one instance thourgh there are many commands in queue.xargs prevents overflower error.

# find ..... | xargs command-op
分类: 科技 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
您必须在 登录 后才能发布评论.