|
| View previous topic :: View next topic |
| Author |
Message |
john maclean
|
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?
#!/bin/bash
# can: a program to put files in a "recyle-bin" like directory
CAN=$HOME/.trashcan;
if [ ! -d $CAN ];
then mkdir $CAN;
fi;
if [ "`echo \"$1\"|cut -c1`" = "-" ];
then case $1 in
-l) echo "$CAN:";
ls -al $CAN
exit 0;;
-r) echo "removeing $CAN/*:"
rm -rf $SCAN/*
exit 0;;
# -z|-?) echo "usage can [-l] [-r] file [file ....]" >&2
# exit 0;;
esac
fi
mv $@ $CAN
|
_________________ BLAG 'em up! |
|
 |
jebba
|
Posted: Wed Aug 11, 2004 12:18 am Post subject: Re: A Bash "reycle bin" script (needs debugging) |
|
|
| john maclean wrote: | | Don't work |
What error do you get?
|
|
|
 |
john maclean
|
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:
<slapped wrist=hard>
|
_________________ BLAG 'em up! |
|
 |
|
|
|