Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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".

share|improve this question

3 Answers 3

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

That should do it.

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

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

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

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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