Find Syntax
Kevin Brunelle
kruptos at mlinux.org
Mon Jan 2 09:59:16 PST 2006
> OK, I understand now. I ultimately want to delete files and was just
> trying to check my command before doing the actual delete. I will use
> '-ls' in my script.
>
> >find . -type f -mtime +1w -exec ls -l {} \;
>
> This works too. Thanks again!
What is your intent with the -ls? Do you need the full listing because I find
that if I just want to know what files are removed the "-print" switch is
cleaner. Or, once I am comfortable that the command is doing what I want,
leaving off the output entirely.
For my temp file deletions I use
/usr/bin/find /home/kevinb/tmp -atime +3 -exec rm {} \;
Yes, I keep my own tmp/ directory below my home directory (it's an old habit).
This command deletes anything I haven't accessed in three or more days. I
use access (-atime) here but modification works just as well. I have that in
a script which cron runs once a day so I can use my temporary folder and not
worry about cleaning up after myself... and I know that anything I put there
I expect to lose unless I find a reason to keep it and move it somewhere
else.
As a word of warning, don't run this in your home directory or in a location
where there are files which will sit around without being used for months at
a time. You would really be upset if ~/.cshrc happened to vanish or any
other file you rely on but don't think of.
-Kevin
More information about the freebsd-questions
mailing list