I'm not quite sure what you are going for, so this might not be helpful, but depending
upon what it you're tying to do, the distinction between the use of ">" and ">>", and
where you use them, might be meaningful as follows:
$ for l in a b c d e f g
> do
> echo $l > this
> done
$ cat this
g
$ for l in a b c d e f g
> do
> echo $l
> done > this
$ cat this
a
b
c
d
e
f
g
$ rm this; for l in a b c d e f g
> do
> echo $l >> this
> done
$ cat this
a
b
c
d
e
f
g
Then too, I don't have any problems doing this in bash:
$ variable_command[1]='echo "a"'
$ variable_command[2]='echo "b"'
$ for fc in 1 2; do ${variable_command[$fc]}; done
"a"
"b"
Sometimes, in any almost any shell, the processing can get confused, or due to a
combination of factors, the result is not exactly what you'd expect if you simply
executed the command from the command line. As in the above, if you just
manually executed:
echo "a"
you would not expect the output to contain the double quotes. But used from
the variable it does. Sometimes the "eval" command can help, as in:
$ for fc in 1 2; do eval ${variable_command[$fc]}; done
a
b
the output is as you'd expect if you just executed the commands from the command
line.
Hope this helps. If not, maybe you can give more details about what you're
trying to do.
|