Friday, 8 July 2011

Linux - Find Command

The find command is used to find files and directories on a linux/unix system. It will search any set of directories that you specify for files/directories matching a given search criteria. You can search by name, owner, group, type, permission, date, and other criteria. Search is recursive and will search the specified directory and its subdirectories providing the user has permission to view the contents of that directory.

Find all files in current directory and it's sub-directories

Find followed by a . will search for all files in the current directory and it's sub-directories and print the output.
dgoh-data-01:oracle@OASLIVE1 > find .
.
./initOASLIVE.ora
./OASLIVEpostupgrade.ora
./spfileOASLIVE.ora
./OASSTBY.stby
./stats_gather.log
./updateusers.sql

Find all sub-directories within the current directory by given owner

If you want to find all sub-directories of the current directory with the owner 'Oracle' then you would execute the following command:
$ find . -type d -user oracle -ls

No comments:

Post a Comment

Please feel free to leave a comment