Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to automatically have the $i variable prepended to the beginning of the command without having to specify it each time?

Here is my current script.


for i in "command -c"; do

$i command1 show

$i command2 show


What I would like is something like this.


for i in "command -c"; do
command1 show

command2 show
share|improve this question
That script does not make sense, try for i in "command -c"; do echo $i; done. I think you mean for i in $(command -c) but in any case, scripting questions are not really on topic here. Why don't you ask this on Unix & Linux instead? – terdon Mar 4 '14 at 19:35
The answer is "no" in general, unless whatever is in $i allows it. – glenn jackman Mar 4 '14 at 21:15
Your question would make more sense if it weren't abusing the Bourne Again shell's built-in commmand command with nonsense options. – JdeBP Mar 4 '14 at 22:46

Your Answer


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

Browse other questions tagged or ask your own question.