$HOME as the path for every example but you may use any other.

1. finding Empty Directory

find $HOME -depth -type d -empty

This will find empty directories in your home directory.

2. Find empty files

find $HOME -depth -type f -empty
This will finde empty common files in your home directory.

3. Find a file with a specific name

find $HOME -name [name_of_file]

This will find files with a given name in any child directory of your home.

4. Find a file with a specific extension

find $HOME -name "*.[given_extension]"

This find files wit the given extension all along your home, an example to find jpg files is:

find $HOME -name '*.jpg'

5. Find files with specific permissions

find $HOME -perm [permission bits]

This will find files with the given permission bits in your home, as an example we can look for .txt files that can have 644 bits on.

find $HOME -name '*.txt' -perm 644

6. Find files with some given permissions and no matter the rest

find $HOME -perm -[permision_bits]

This will find files in your home that have match with the given permissions but that can also have some others, as an example:

find $HOME -name '*.txt' -perm -644

This will find the files with 644 but also some with 664 or 777 or anything “greater” than 644.

Other example :
find $HOME -name '*.txt' -perm 644 -exec ls -l {} \;
find $HOME -name '*.txt' -perm -644 -exec ls -l {} \;

As you may see in the first example we do not have the file post as it has 664 permissions, so do not exactly match 644, but on the second output, it is listed as it has “greater” permissions than 644.

7. Find files of given sizes

find -size n[cwbkMG]

This will output the files of a given block size, as an example we can see:

find $HOME -name '*.txt' -size 4k -exec ls -l {} \;
Now let’s see this other:

find $HOME -name '*.txt' -size 5k -exec ls -l {} \;

if you divide each file size by 1024 (1k) you will see that the first output is always lower than 4096 (4k) and upper 3072 (3k), on the second output you have it between 4096 (4k) and 5120 (5k).

8. Find files with a give name and any extension


find -name '[given_name].*'

This will output the files of any given name but with any extension

9. Find files modified in the latest blocks of 24 hours

find -mtime n

Where n is:

0 for the last 24 hours
1 for the last 48 hours
2 for the last 72 hours

and so on.

10. Find files that was accessed in the latests blocks of 24 hours

find -atime n

Where n is:

0 for the last 24 hours
1 for the last 48 hours
2 for the last 72 hours

and so on.

11. Finding a file based on filename

Let say for instance you want to find all .avi files in users home directories. Search files can be found with the following command:

# find /home -name '*.avi'

If you want to search for *.mpg and *.avi files, you will use the following:

find /home -name '*.mpg' -o -name '*.avi'

Case insensitive searches can be achieved by using the -iname switch:

find /home -iname '*.mpg' -o -iname '*.avi'

12. Adding some more criterias

Those kind of searches might returns far too many results, making it hard to find waht you were looking for in the first place.

Fortunately, you can narrow down the search by adding criteria such as the file size and the file modification date.

Let’search for .avi files bigger than 700M. This can be done with:

find /home/ -name '*.avi' -a -size +700M

Now, let’s find the same subset of files that were modified less than 15 days ago:

find /home/ -name '*.avi' -a -size +700M -mtime -15

13. Adding some actions

Grand, we can now find files based on a subset of criteria. What would be even better is to apply some actions on those files. Action can be done with the use of -exec switch.
We can now find .avi file that are newer that 15 days, in this example, we are going to move those file to another location: /my/new/movies . I consider that this directory already exist on your system.
Moving .avi files bigger than 700M and younger than 15 days to /my/new/movies can be done with:

find /home/ -name '*.avi' -a -size +700M -mtime -15 -exec mv '{}' /my/new/movies/ \;

Mind the use of ‘{}’ and \; (there is a space before \;).
‘{}’ matches the file that was found, while \; terminate the exec statement.