Thursday, 7 May 2015

find command in Linux - Examples


The Linux Find Command is one of the most important and much used command in Linux sytems. Find command used to search and locate list of files and directories based on conditions you specify for files that match the arguments. Find can be used in variety of conditions like you can find files by permissions, users, groups, file type, date, size and other possible criteria.

Basic Examples:

1)
List all files in current and sub directories

This command lists out all the files in the current directory as well as the subdirectories in the current directory.
     

        OR find . gives the same output.

2)
Search specific directory or path
The following command will look for files in the test directory in the current directory. Lists out all files by default.






The following command searches for files by their name in that specified directory.




We can also find file or directory with wild charecter.




3)
Limit depth of directory traversal



4)
Invert match

It is also possible to search for files that do no match a given name or pattern. using -not option.