I have 3 aliases. They are named echo1, echo2, echo3
How do i execute all 3 of them as part of a larger command?
$ alias echo1='echo 1'
$ alias echo2='echo 2'
$ alias echo3='echo 3'
$ echo1
1
$ echo2
2
$ echo3
3
$ echo{1..3}
bash: echo1: command not found
$ bash -ic echo{1..3}
echo2: echo1: command not found
$ bash -ic 'echo{1..3}'
bash: echo1: command not found
Solution: based on Kusalananda's answer:
printf '%s\n' {1..3} | xargs -I {} bash -ic "echo{}"
man bash
, which does surprise me. However, aliases defined in the current shell aren't inherited by child shells, so I wouldn't expectbash -ic aliasname
to work regardless of brace expansion.alias1 alias2 alias3
would only ever run one alias. So why would you wantalias{1..3}
to do that anyway? Just runalias1;alias2;alias3
. If you want to run multiple aliases with the same arguments, you shouldn't be using aliases; you should be using a single function which encompasses the purposes of all three aliases. See unix.stackexchange.com/q/30925/135943