Posted: Tue Aug 10, 2004 11:49 am Post subject: A Bash "reycle bin" script (needs debugging)
I was looking for a "recycle bin" type script. This would move removed files to a dir rather than incinerating them. I came across this code from "Tricks of the unix masters", R. Sage 1985. Don't work :( Anyone care to debugg?
# can: a program to put files in a "recyle-bin" like directory
if [ ! -d $CAN ];
then mkdir $CAN;
if [ "`echo \"$1\"|cut -c1`" = "-" ];
then case $1 in
-l) echo "$CAN:";
ls -al $CAN
-r) echo "removeing $CAN/*:"
rm -rf $SCAN/*
# -z|-?) echo "usage can [-l] [-r] file [file ....]" >&2
# exit 0;;
mv $@ $CAN
_________________ BLAG 'em up!
Posted: Wed Aug 11, 2004 12:18 am Post subject: Re: A Bash "reycle bin" script (needs debugging)
john maclean wrote:
What error do you get?
Posted: Wed Aug 11, 2004 11:50 pm Post subject:
Sorry guys there was a typo in the code. The variable $SCAN should read $CAN.
It works now and also allows options that would be valid for 'mv'. I've only rm'ed and lost important files once. That was once too much :oops: