Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


find ? | 18 comments | Create New Account
Click here to return to the 'find ?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
find ?
Authored by: TonyT on Jul 03, '07 05:31:09PM

Same at the command line:

$ ls -latu
drwxr-xr-x 2 Tony Tony 68 Jul 3 20:26 untitled folder 2

/usr/bin/find /Users/Tony/.Trash -mindepth 1 -maxdepth 1 -not -newerat '7 days ago' -delete

$ ls -latu
drwxr-xr-x 2 Tony Tony 68 Jul 3 20:29 untitled folder 2

I'm running OS X 10.4.10 on an Intel MacBooh



[ Reply to This | # ]
find ?
Authored by: Soliman on Jul 04, '07 01:36:39AM
Ok, I finally got it : for me it works because find doesn't change the atime of files but changes that of directories !!!

The solution ? Change -maxdepth 1 to -prune, which gives :

/usr/bin/find /Users/[blabla]/.Trash -mindepth 1 -prune -not -newerat '3 days ago' -delete :)

---
Sylvain

[ Reply to This | # ]

find ?
Authored by: TonyT on Jul 04, '07 12:47:27PM

I had already tried -prune without success:

$ ls -latu
drwxr-xr-x 2 Tony Tony 68 Jul 4 15:39 untitled folder 2

$ /usr/bin/find /Users/Tony/.Trash -mindepth 1 -prune -not -newerat '7 days ago' -delete

$ ls -latu
drwxr-xr-x 2 Tony Tony 68 Jul 4 15:43 untitled folder 2

-newermt seems to be my only solution.

What ver of OS X are you running?



[ Reply to This | # ]
find ?
Authored by: Soliman on Jul 05, '07 01:20:51AM
I run OSX 10.4.10, however if I didn't notice the problem it is probably because I didn't have any directory in my Trash, only "flat" files (and for them no access time change)...

To solve the directories problem something like the following might work :
/usr/bin/find -d .Trash -mindepth 1 \( -type d -and -empty \) -or \( -not -newerat '3 days ago' \) -delete

But it doesn't seem to work as I expected (-or problem ?), whereas separating the two commands does what it should...

---
Sylvain

[ Reply to This | # ]

find ?
Authored by: Soliman on Jul 05, '07 09:02:26AM
Actually I discovered that the problem is caused by -delete so changing it to use rm seems ok.

Here is my new crontab entry :
/usr/bin/find /path/to/.Trash -mindepth 1 -prune -not -newerat '7 days ago' -exec /bin/rm -Rfv {} \;

DISCLAIMER: use rm -Rf at your own risk ;)

---
Sylvain

[ Reply to This | # ]