Set up a trash/bin for your server
Who never wanted to have a bin installed on his server.Who never wanted to have such a tool to provide rm errors.
Well here is a way to never been worried any more about this accident.
To move something to bin with this script you'll have to use the del command.
1 : Create a file /bin/del , chmod 755
2 : follow :
-----------------
#!/bin/bash
if [ -z $1 ]; then
echo 'del : file or dir not specified'
exit 1
fi
timestamp=`date '+%s'`
while [ $# -ge 1 ]; do
file=`echo $1 | sed 's/\/$//'`
if [ ! -e $file ]; then
echo "del : file or dir '$file' doesnt exists"
else
echo -n "del : are you sure you want to delete '$file' ? [y/n] "
read confirm
if [ -z $confirm ]; then
confirm='n'
fi
if [ $confirm == 'y' ]; then
echo " ... '$file' has been deleted..."
file_name=`basename $file`
mv $file /trash/$file_name-$timestamp
fi
fi
shift
done
for i in `ls -1 /trash/` ; do
taille=`echo ${#i}`
deltime=${i:$taille-10:10}
diff=`expr $timestamp - $deltime`
if [ $diff -gt 2592000 ]; then
rm -rf /trash/$i
fi
done
exit 0
-----------------
3 : create a dir named /trash :
mkdir /trash
You could also create a link from /trash to /home/bin if you like.
Now when you want to delete a file make
=> "del file" or
=> del "file*" or
=> "del *" and it will be automatically placed in the bin. It works for the dir too.
Little Add :
1/Parameters like "del -f" wont work. ^_^
2/You could also use the mv command to move it to /trash. Also possible to add a crontab to delete automatically the old file (for example after 48 hours)
Hope this will help some of the WHTers.
I'll post other tutorials like that to help those who need it.
Happy Christmas.

PS : I've tried my best to explain it in english, please ask if you dont understand. I've made it in french first so tell if you have issues.