I want to create two different aliases to the same command without repeating myself. How can I do it in bash? For example, I want listlong and longlist to both be aliases to "ls -al".

link|improve this question

71% accept rate
feedback

3 Answers

up vote 9 down vote accepted
alias {listlong,longlist}="ls -al"

That should do it.

link|improve this answer
feedback
alias listlong='ls -al'
alias longlist=listlong

And further changes of the alias listlong reflect on longlist too.

link|improve this answer
I prefer this method because it requires less understanding of bash :-) – Torben Gundtofte-Bruun Sep 7 '10 at 13:32
feedback

Here's a variation on cYrus's answer with even less repetition:

alias listlong='ls -al' longlist=listlong

If you want to do something similar but have them be independent:

cmd='ls -al'; alias listlong=$cmd longlist=$cmd

which has similar results to Janne Pikkarainen's answer (which is the least repetitive so far).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.