Link to home
Start Free TrialLog in
Avatar of sunhux
sunhux

asked on

Shell script & good way to prevent accidental Unix " rm -r * " : Linux & HP-UX


Can anyone provide a Shell script such that if

a) if the person issues "rm -r *", the script will check if the current directory
    is / or /var or /usr or /oracle (or any additional directories that I may add
    from time to time),  it will not echo out a message, you are about to execute
    a dangerous delete from `pwd` & then come back to command prompt

b) if the person issues "rm *" or "rm *.*", it will do a confirmation, whether
    to proceed besides echoing "Alert, you're in `pwd`, confirm to proceed? "


Any other way to prevent accidental deletion of files are welcome.

I'm concerned that if I replace the "rm" binary with the above "rm" script,
certain cron or jobs may fail
SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial