Interactive 2.2 File zapper.
Rahul Dhesi
dhesi%cirrusl at oliveb.ATC.olivetti.com
Thu Aug 2 03:56:14 AEST 1990
>-- cd /lost+found
>-- find . -mtime +14 -exec rm -rf {} \;
>If there's no lost and found directory in the root file system, this deletes
>everything in the system that's older than 14 days.
The last time I looked, it was an undocumented feature in sh and csh
(and probably in ksh though I didn't check) that a cd that failed would
abort the rest of the script. In fact, sh and csh (but not ksh) went a
bit too far, and the statement
cd dir || exit 1
would never execute the exit 1.
It looks like the sh you are using has had this undocumented feature
removed, resulting in disaster.
Standard practice in cleanup scripts is to do a cd followed by
something else on the same line:
cd /lost+found; find . -mtime +14 -exec rm -rf {} \;
If the cd fails, no damage is done, because the rest of the line is not
executed. Any sensible shell ought to let at least this work, even if
it doesn't abort the entire script.
--
Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
UUCP: oliveb!cirrusl!dhesi
More information about the Comp.unix.wizards
mailing list