Linux Shell : find
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