Alias - Adding Command with Arguments
Hi,
In my .bashrc, I have this entry. alias rm='echo mv $1 /tmp/.rm' If I try to use this command, home@home]#> rm test.txt It will give this output. home@home]#> echo mv /tmp/.rm test.txt What I want is actually this output home@home]#> echo mv test.txt /tmp/.rm Any ideas? Thanks, bichonfrise74 |
It's simple. You can't do that with an alias. Aliases are limited to simple substitutions. If you want to do something more complex like this, you need to set it up as a shell function. Create a function and put it in your bashrc, and the command will be available just like an alias would.
A nice short description of aliases and functions can be found at LinuxCommand.org |
Also, a single quote is exactly passed, so effectively, the command that is being executed is
'echo mv $1 /tmp/.rm' followed by $1 So maybe, you can substitute double-quotes for single-quotes. End |
All times are GMT -5. The time now is 08:28 PM. |