Maddy's Rant

Vacuous, vivid, vivacious, aphrodisiac, simulating, rapid, ravenous

Name:
Location: Bellevue, WA, United States

Come and sit with me my friend, I promise to show you the world beyond your wildest imagination.

Monday, June 06, 2005

'Find'ing in UNIX Variants

One thing which really piss me off is my ability to remember proper commands and lack of
patience to read the man pages. Here is the list of reference I collected for FINDing files in
UNIX. (Tuned to what I wan't).

find / -name Chapter1 -type f -print

This command searches through the root filesystem ("/") for the file named "Chapter1". If it finds the file, it prints the location to the screen.

find /usr -name Chapter1 -type f -print

This command searches through the "/usr" directory for the file named "Chapter1".

find /usr -name "Chapter*" -type f -print

This command searches through the "/usr" directory for all files that begin with the letters "Chapter". The filename can end with any other combination of characters.

This will match filenames such as "Chapter", "Chapter1", "Chapter1.bad", "Chapter_in_life".

find /usr/local -name "*.html" -type f -print

This command searches through the "/usr/local" directory for files that end with the extension ".html". These file locations are then printed to the screen.

find /usr/local -name "*.html" -type f
-exec chmod 644 {} \;

This command searches through the "/usr/local" directory for files that end with the extension ".html". When these files are found, their permission is changed to mode 644 (rw-r--r--).

find htdocs cgi-bin -name "*.cgi" -type f
-exec chmod 755 {} \;

This command searches through the "htdocs" and "cgi-bin" directories for files that end with the extension ".cgi". When these files are found, their permission is changed to mode 755 (rwxr-xr-x). This example shows that the find command can easily search through multiple sub-directories (htdocs, cgi-bin) at one time.


References
------------
This document is adopted from http://www.devdaily.com/unix/edu/examples/find.shtml

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home