Friday, November 26, 2010

Find command demystified.

find command is cool tool for searching lost items. Lets find the mystery in 'find':

>find -name “abc.jpg”
is directory in which file is to be searched. Eg. '.' for present working directory. '/' for root [of course without single quotes].


In using wildcards * denotes the part of file you don't remember or you're not sure. Suppose your searching the file mission-impossible-3.mov. Some of the possible find searches could be:
>find -name "mission*"
>find -name "*mission*"
>find -name "*impossible*"
>find -name "mission*.mp3"


Now, use find commands to search for files as per their size. +100M is used for file > 100Mb,similarly -100Mb for file < 100MB. G for Gb & k for kb. find -size +100M
find -size +10G
find -size +100k
find -size -100M


Searching files with a particular extension
>find -name "*.mp3"
>find -name "*.png"

Search according to the time of previous access of the file.
>find -amin -10 -name "*.doc"
>find -mmin -10 -name "*.doc"
-10 for file access/modified in last 10 minutes. -amin/-mmin for files accessed/modified. [note -a & -m in -amin/-mmin].

More will be covered in the next post!

No comments:

Post a Comment