Quote:
Originally Posted by gammalyrae
Perhaps an alias or function for rm in your bashrc that first makes a copy of the file somewhere and then deletes it.
eg:
rm1 ()
{
cp $1 ~/backup
rm $1
}
|
First, I forgot to update my question that I had tried using an alias in the
.bashrc file and created a script which is called when
rm is executed. It would create a
file so that I would have a smaller version of the deleted file as a backup.
Anyways, the idea of putting a function is the
.bashrc is really much better and efficient.
So, I just experimented with it:
Code:
[DEV@mahadeva ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
go ()
{
cp $1 ~/recycle
rm $1
}
[DEV@mahadeva ~]$
To reload the .bashrc file:
Code:
[DEV@mahadeva ~]$ . .bashrc
Code:
[DEV@mahadeva ~]$ cal > test
[DEV@mahadeva ~]$ mkdir recycle
[DEV@mahadeva ~]$ ls
recycle test
[DEV@mahadeva ~]$ go test
rm: remove regular file `test'? y
[DEV@mahadeva ~]$ ls
end intro recycle
[DEV@mahadeva ~]$ ls recycle/
test
[DEV@mahadeva ~]$
Isn't that cool?
Thanks Gurus!
