Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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).
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.