Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Aug 2006 19:20:50 -0700
From:      David King <dking@ketralnis.com>
To:        Daniel Gerzo <danger@rulez.sk>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Undelete for UFS2?
Message-ID:  <4CDA93C2-B453-4FF8-B4FF-53FA7FCC089C@ketralnis.com>
In-Reply-To: <531772590.20060812103027@rulez.sk>
References:  <44DD336C.1080403@comcast.net> <531772590.20060812103027@rulez.sk>

next in thread | previous in thread | raw e-mail | index | archive | help
>> Lastly surely someone has implemented a trash folder mechanism for
>> freebsd... what is it called so I can look up how to install it?
>
> maybe something like:
> mkdir ~/.trash
> alias rm     'mv -iv \!* ~/.trash/'

The problem with that solution is that when you move to a new system,  
you assume that your files will go to trash and then OH NO

Better to do something like:
	alias del 'mv -iv \!* ~/.trash/'
and get in the habit of using 'del'

Or maybe a script called 'del' in your path that looks like (I use  
this one):

#!/bin/sh

DATESUFFIX=`date -u +%Y-%m-%d--%H.%M.%S` # All files deleted at the  
same time need the same serial
LOCATION=${HOME}/.Trash

if [ \! -d ${LOCATION} ]; then
     echo Creating $LOCATION...>&2
     mkdir ${LOCATION}
     chmod 700 ${LOCATION}
fi
if [ \! -z $SUDO_USER ]; then
     THE_USER=$SUDO_USER
else
     THE_USER=$USER
fi

for each in "$@"; do
     if [ -e "$each" ]; then
         NEWFILE=${LOCATION}/`echo "$each" | tr / _`.${DATESUFFIX}
         echo -n $each '->' ${NEWFILE}
         mv "$each" "${NEWFILE}"
         chown -R $THE_USER "${NEWFILE}"
         echo .
     else
         echo \"$each\" was not found >&2
     fi
done

if [ \! -z "$PS1" ] || [ \! -z "$PROMPT" ]; then
     printf "Your trash can has %s and %s inodes\n" `du -hcd0  
$LOCATION 2>/dev/null | tail -n 1 | awk '{print $1}'` `find $LOCATION| 
wc -l`
fi





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CDA93C2-B453-4FF8-B4FF-53FA7FCC089C>