FIND Commands
FIND Commands
The action expressions are used to define actions that have side effects
and may return true or false. If not actions are specified, the ‘-print’ action
is performed for all matching files.
List all files found in the current directory and its hierarchy
$ find.
List all files found in the current hierarchy, and all the hierarchy
below /home/xyz
$ find. /home/XYZ
Search for a file by the name abc in the current directory and its
hierarchy
$ find ./ -name abc
Search for a file by the name abc.txt below the current directory,
and prompt the user to delete each match.
Note that the “{}” string is substituted by the actual file name while
running and that the “\;” string is used to terminate the command to be
executed.
Search for files that were modified in the last 7 days below the
current directory
$ find ./ -mtime -7
Search for files that have all permissions set in the current
hierarchy
$ find ./ -perm 777
Conclusion
In short, Find Command in Unix returns all files below the current working
directory. Further, find command allows the user to specify an action to be
taken on each matched file.