Find |
The find command is a search utility found on the Unix platform that can search through the directory tree of the filesystem locating files based on some user-specified criteria. By default, find simply returns all files below the current working directory. Further, find allows the user to relate some action to be taken on each matched file.
=man page=
The man page for the GNU find command can be found at [http://unixhelp.ed.ac.uk/CGI/man-cgifind unixhelp]. If you have Unix and this man page installed, you can see it by simply typing man find .
=Doing a Simple Search=
==Search it All==
find / -name myfile -type f -print This searches every file on the computer for a file with the name myfile , so it is generally not a good idea to look for data files this way. This can take a considerable amount of time, so it is best to specify a directory.
==Specify Directories==
find /home/brian -name myfile -type f -print This searches for files named myfile in the /home/brian directory, which is the home directory for the user brian . You should always specify the directory to the deepest level you can remember.
==More Than Display==
This command actually changes modes of files: find /var/ftp/mp3 -name *.mp3 -type f -exec chmod 744 {} ; This will change all of the files with a name ending in .mp3 in the directory /var/ftp/mp3 to have their mode changed to 744, or rwxr--r--. This gives you full permission to read, write, and execute the files. However, other users will only have read-only access to the files.
==Recreate a directory structure (without files)==
This command finds the directories within the current directory and makes the new directories in the ~/outputDirectory . find -type d -exec mkdir -p ~/outputDirectory/{} ; Note: ~/ represents your home directory (e.g. /home/joeBloggs).
=Free Software Implementations=
|
|