find - used in finding content in directory hierarchy
Syntax:
find <path> [options] <search pattern>
Examples:
find . -name ".txt"
find . -iname "foo"
find . -maxdepth 1 -iname "foo"
find ./abc -name foo.txt
find . -type f
find . -size +100Kb
find ./abc -mtime -1
find . -mmin -45
find . -name *.txt ! -name abc
Syntax:
find <path> [options] <search pattern>
Searching and listing of files ending with file extension .txt in current folder and its sub-folders
find . -iname "foo"
Searches the case insensitive patterns foo and FOO and lists the matched pattern
find . -maxdepth 1 -iname "foo"
Searches the case insensitive pattern in the current folder only. Maxdepth specifies the hierarchy of search.
find ./abc -name foo.txt
Searches for the foo.txt named file in the directory abc existing in current directory
find . -user Mark
Lists all content belonging to user Mark
find . -type d
Lists all directory and subdirectory names
find . -type f
Lists all files in current directory and subdirectories
find . -size +100Kb
It lists all files whose size is greater than 100Kb
find ./abc -mtime -1
Lists the files present in abc directory which were modified within last day (i.e within 24 hours)
find . -mmin -45
Lists the files which were modified within last 45 minutes.
find . -name *.txt ! -name abc
Lists .txt files present in current directory whose names does not start with abc.