On Mon, Nov 7, 2011 at 12:56 PM, Peng Yu <[email protected]> wrote:
> Hi Clark,
>
> >> > v=" a b c ( a'b | "
> >> > a=( $v )
> >> > echo "${a[@]}"
> >
> > There's a @ char here.
>
> I see. It's my mistake.
>
> But I want to pass the 6 short arguments instead of 1 long argument to
> echo.
What do you mean by "1 long argument"?
[bash-4.2.10] # cat foo.sh
v=" a b c ( a'b | "
set -o noglob
a=( $v )
set +o noglob
for i in "${a[@]}"; do
echo "$i"
done
[bash-4.2.10] # bash foo.sh
a
b
c
(
a'b
|
[bash-4.2.10] #
> (echo is just an example, it can be any command that accepts
> multiple arguments.)
>
>
> ~$ cat ./main1.sh
> #!/usr/bin/env bash
>
> #set -o noglob
> verbatim_string=" a b c ( a'b | "
>
> args=( $verbatim_string )
> #set +o noglob
>
> echo "${args[@]}"
>
> ~$ ./main1.sh
> a b c ( a'b |
>
>
> --
> Regards,
> Peng
>