Content added Content deleted
No edit summary |
imported>DrOwl (added some more examples) |
||
Line 8: | Line 8: | ||
If you want to suppress error messages such as |
=== If you want to suppress error messages such as === |
||
find / -name file |
find / -name file |
||
Line 19: | Line 19: | ||
/dir/file |
/dir/file |
||
<pre> |
|||
EXAMPLE : find /var/log/ -name "20*-*-*_*.log*" -mtime +80 -exec rm {} \; |
EXAMPLE : find /var/log/ -name "20*-*-*_*.log*" -mtime +80 -exec rm {} \; |
||
deletes all files older than 80 days |
deletes all files older than 80 days |
||
</pre> |
|||
=== Find files files accessed more then +n, less then -n days === |
|||
find . -mtime -100 |
|||
find . -mtime +100 |
|||
=== Find and delete all files not access for more then 24 hours === |
|||
find . -atime +1 -exec rm '{}' \; |
|||
=== Grep through all files recursively === |
|||
find / -type f -exec grep -li 192.168.1.76 {} \; |
Latest revision as of 09:20, 5 August 2008
<man>find</man>
Tips[edit]
If you want to suppress error messages such as[edit]
find / -name file find: cannot read dir /lost+found: Permission denied /dir/file
as these messages are written to errout and not stdout, a nice trick is to pipe errout to null
find / -name file 2> /dev/null /dir/file
EXAMPLE : find /var/log/ -name "20*-*-*_*.log*" -mtime +80 -exec rm {} \; deletes all files older than 80 days
Find files files accessed more then +n, less then -n days[edit]
find . -mtime -100 find . -mtime +100
Find and delete all files not access for more then 24 hours[edit]
find . -atime +1 -exec rm '{}' \;
Grep through all files recursively[edit]
find / -type f -exec grep -li 192.168.1.76 {} \;