I want to insert into alias different possible variants of spelling, for example, cat command. Can I do it using some symbol for 'or' or should it be on a new line?

alias at|cart|cst '/bin/cat'
up vote 17 down vote accepted

The help for alias indicates that it can assign multiple aliases at once:

alias: alias [-p] [name[=value] ... ]
    Define or display aliases.

    Without arguments, `alias' prints the list of aliases in the reusable
    form `alias NAME=VALUE' on standard output.

    Otherwise, an alias is defined for each NAME whose VALUE is given.
    A trailing space in VALUE causes the next word to be checked for
    alias substitution when the alias is expanded.

So you can use brace expansion to generate the name=value pairs:

alias {at,cart,cst}='/bin/cat'


$ alias {at,cart,cst}='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'

That said, look in to zsh, which has built-in typo correction (which wouldn't help for at, but it would help for the others):

% setopt correct
% sl
zsh: correct `sl' to `ls' [nyae]? y
% setopt correctall
% ls x.v11r4
zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
/usr/princton/src/x.v11r4 not found
% ls /etc/paswd
zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y

If you press y when the shell asks you if you want to correct a word, it will be corrected. If you press n, it will be left alone. Pressing a aborts the command, and pressing e brings the line up for editing again, in case you agree the word is spelled wrong but you don't like the correction.

I don't think you can assign multiple aliases at once.
But you could loop through a list like this:

for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done

Make sure that the aliases are not already in use by other programs (like at in your example).

  • Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end. – Josef Klimuk May 16 at 9:49
  • 2
    @JosefKlimuk: Sounds like it would be worth its own answer. :-) – David Foerster May 16 at 10:22
  • @David Foerster, Should I ask it as independent question? – Josef Klimuk May 16 at 10:37
  • 2
    @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment. – David Foerster May 16 at 16:09

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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