LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   alias two words or more (https://www.linuxquestions.org/questions/linux-newbie-8/alias-two-words-or-more-187881/)

chii-chan 05-31-2004 01:36 AM

alias two words or more
 
Hi. I think this question is kind of stupid. Usually when you set alias in your ~/.bashrc file, you make it consist of one word like this:

alias rm='rm -i'

But what if I want to make the alias to consist of two words or more. I've tried this:

alias remove\ junks='rm -i'
alias "remove junks"='rm -i'
alias 'remove junks'='rm -i'

And I want space between the words so that when I type something like:

Code:

remove junks junk.file
, it would do
Code:

rm -i junk.file
for me. Or there limitation for alias command? Thanks.

trickykid 05-31-2004 01:46 AM

I'm not an alias expert but feel that wouldn't work out so well.. why not just write a basic shell script to do this, with options, etc?

micxz 05-31-2004 01:48 AM

rm is short for remove so your theory of making a two word alias does not make much sense to me. In fact you unaliasing in this case. And yes I beleive the built in command for alias does not accept two arguments:
alias [-p] [name[=value] ...]

trickykid 05-31-2004 01:49 AM

Quote:

Originally posted by micxz
rm is short for remove so your theory of making a two word alias does not make much sense to me. In fact you unaliasing in this case. And yes I beleive the built in command for alias does not accept two arguments:
alias [-p] [name[=value] ...]

Also I would think typing rm -i junk.file would be easier to type than remove junks junk.file as well.. ;)

micxz 05-31-2004 01:54 AM

You could use `remove_junk` then hopefully when you type "rem"+TAB you should get what you want. Pretty silly if you ask me. But you may have some other function for this in mind'

chii-chan 05-31-2004 02:00 AM

Yeah! Just to make the command line to understand normal words:). Even when I make a script 'remove junk', I cannot run it unless I put the '\' in between. I think I should make a script that accept command from echo -n instead. Thanks guy.


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