FAQ   Search   Memberlist  
Profile    Log in to check your private messages    Register    Log in
A Bash "reycle bin" script (needs debugging)

 
Post new topic   Reply to topic    BLAG Forum Index -> open discussion
View previous topic :: View next topic  
Author Message
john maclean
PostPosted: Tue Aug 10, 2004 11:49 am    Post subject: A Bash "reycle bin" script (needs debugging) Reply with quote

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
PostPosted: Wed Aug 11, 2004 12:18 am    Post subject: Re: A Bash "reycle bin" script (needs debugging) Reply with quote

john maclean wrote:
Don't work


What error do you get?

john maclean
PostPosted: Wed Aug 11, 2004 11:50 pm    Post subject: Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    BLAG Forum Index -> open discussion
Page 1 of 1

Protected by Anti-Spam ACP