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{}"
echo1 echo2 echo3
it would not accomplish what you intend, though. – Wildcard Jun 01 '17 at 01:32man 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. – Wildcard Jun 01 '17 at 01:34alias1 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 https://unix.stackexchange.com/q/30925/135943 – Wildcard Jun 01 '17 at 01:43eval
is a problem, not a solution. ;) At least 99.9% of the time there is a better solution thaneval
. I doubt you've hit the 0.1% here. – Wildcard Jun 01 '17 at 03:51$i
ie.
– yosefrow Jun 01 '17 at 04:18command$i some-parameter