BLAG

BLAG Forums
It is currently Tue Dec 23, 2014 4:25 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Aug 10, 2004 11:49 am 
Offline
Site Admin

Joined: Wed Mar 17, 2004 6:17 pm
Posts: 1340
Location: London, UK
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!


Top
 Profile  
 
PostPosted: Wed Aug 11, 2004 12:18 am 
Offline
Site Admin

Joined: Sun Mar 14, 2004 3:17 pm
Posts: 4492
Location: Loveland, Colorado, USA
john maclean wrote:
Don't work


What error do you get?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 11:50 pm 
Offline
Site Admin

Joined: Wed Mar 17, 2004 6:17 pm
Posts: 1340
Location: London, UK
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group