LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   is it a trivial prblem? (https://www.linuxquestions.org/questions/linux-general-1/is-it-a-trivial-prblem-523431/)

thtr2k 01-28-2007 03:44 AM

is it a trivial prblem?
 
Hi,
I just want to use rm as an mv in the command line to a folder called recycle and later if i really want to delete the file(s) i will delete manually. i have put this "alias rm='mv \!* ~/recycle" in the file .bash_aliases, but it didn't work. Can someone tell me why (i think it cant be bash shell) and how i would overcome the problem. One more question, how do i make mv to really move files to a different folder with a check to see if the file(s) exist. if files existed replace the extension otherwise do as normal. I think i have to use a script but i don't know and how to link/execute, could it be loaded up automatically as i open the terminal.
Thanks in advance

b0uncer 01-28-2007 03:52 AM

I assume you logged out and then logged back in, since the file you mentioned might not be read before that; you could just issue the alias command in your terminal to make it work immediately (though it is "forgotten" after you log out unless you put it in the bash's file).

To make more complicated things you just create a script and then either rename real rm and put the script in place of it, and make the script use the renamed rm, or if you like, create a symbolic link called rm that points to the script file if you don't like to put it in the bin directory (and still have the real rm renamed so that it's not overwritten).

thtr2k 01-29-2007 12:10 AM

Quote:

Originally Posted by b0uncer
I assume you logged out and then logged back in, since the file you mentioned might not be read before that; you could just issue the alias command in your terminal to make it work immediately (though it is "forgotten" after you log out unless you put it in the bash's file).

what the ... i know that. i ran "source .bash_aliases" and my .bash_aliases file is already enable in the .bashrc file. i also closed the terminal and reopen it. According to what is said i don't think the command "alias rm='mv \!* ~/recycle" works in bash shell.
Quote:

Originally Posted by b0uncer
To make more complicated things you just create a script and then either rename real rm and put the script in place of it, and make the script use the renamed rm, or if you like, create a symbolic link called rm that points to the script file if you don't like to put it in the bin directory (and still have the real rm renamed so that it's not overwritten).

Great help

trickykid 01-29-2007 12:19 AM

Is that how it exactly looks in your bash_aliases file? How exactly do you have it in your bash_aliases file?

thtr2k 01-29-2007 08:32 AM

yes, indeed.
in .bash_aliases file:
alias rm='mv /!* ~/recycle'
in .bashrc file:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

ps: i'm using ubuntu edgy


All times are GMT -5. The time now is 01:43 AM.