- To remove all files named 'a.out' or '*.o' that have not been accessed for a week:
- find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \;
- The rm command is executed once for each file.
- find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} +
- To find all files below the directory 'documents' that contain the regular expression 'string':
- find documents -type f -exec grep string {} +
- To find all files in the directory 'home', not descending into its subdirectories:
- find home ! -name home -prune
- To check whether the file 'diary' has been updated within the last two days; the name of the file is printed if true, and is not printed otherwise:
- find diary -prune -mtime -2
Saturday, October 22, 2005
The HELL that find is!
Short tutorial on Linux find command.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment