|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
|
Clearly, your use of the UNIX find command is limited only by your
knowledge and creativity. The find command has a lot of options, and to get
the full power out of find, xargs, and grep, you need to experiment.
Among other things you can specify:
| Option | Meaning | Example |
|---|---|---|
| -atime n -atime +n -atime -n -size |
True if file was accessed n 24-hour periods (days) ago (n), accessed more then n 24-hour periods (days) ago(+n) or less than n 24-hour periods (days) ago (-n) |
|
| -ctime n | True if the file was created n 24-hour periods (days) ago. | find . -ctime +30 -type f -exec rm {} ';' |
| -exec command | Execute command. | find . -mtime -2 -type f -exec mv {} ../Spam_collector \; |
| -mtime n | True if file was modified n 24-hour periods (days) ago. | find . -mtime -2 -type f -exec mv {} ../Spam_collector \; |
| -name pattern | True if filename matches pattern. | |
| Print names of files found. | ||
| -type c | True if file is of type c | find . -mtime -2 -type f -exec mv {} ../Spam_collector \; |
| -user name | True if file is owned by user name. |
Multiple options are joined by AND by default. OR may be specified with the -o flag and the use of grouped parentheses. For example, to match all files modified more than 90 24-hour periods (days) ago or accessed more than 30 24-hour periods (days) ago, use
\( -mtime +90 -o -atime +30 \)
NOT should be specified with a backslash before exclamation point. For example, to match all files ending in .txt except the file starting with "a-z", use:
\! -name "[a-z]*" -name "*.txt"
Copyright © 1996-2008 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Created: May 16, 1997; Last modified: July 17, 2008