Unix Shell - safe rm shell script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2005 > safe rm shell script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author safe rm shell script
william

2005-09-20, 6:05 pm

Hi,

Anyone know if there is a safe rm shell script, which will mv files to
a
deleted directory?

--
Regards

William

sandy_eggo

2005-09-20, 6:05 pm

Many people like to alias rm to rm -i (or have another alias for it, so
they don't rely on rm being rm -i), but for large numbers of files,
that's pretty tedious. What you really want is for it to list the
files, and you can confirm it all at once:

alias del '/bin/ls -AsF \!* && echo -n "Remove? " && if ($< == y)
/bin/rm -rf \!*'

This lists all files and the contents of any directories specified (but
does not do a recursive listing, which is often too long), asks for
confirmation and deletes only if the response is y.

Another way would be to move the file to %HOME/Trash and then
periodically empty it...

# Move file to tmp:
mv $* $HOME/Trash
find $HOME/Trash -name '*' -type f -ok rm {} \;

HTH,
Carlos

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com