Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You must log in to answer this question.

Browse other questions tagged .