What does this do in bash: [@]?

Jon LaBadie ubu at labadie.us
Sat Jul 30 04:57:53 UTC 2022


On Fri, Jul 29, 2022 at 05:43:01PM +0200, Bo Berglund wrote:
>I am trying to understand the working of a script example I am trying to adapt
>but cannot think up a useful google search command to get to a description....
>
>In the script there is this:
>
>URL=('https://tokens.somesite.com' + long stretch of arguments)
>
>Then later:
>INPUT=$(curl -qsS "${URL[@]}"  | some processing stuff)
>
>What I do not know is what the [@] in "${URL[@]}" does???
>
>Where can I read bout this?
>

I may be reading this differently than other posters.

A=(a b c d)  is a syntax for creating an array "A" with 4 elements.

URL=('https://tokens.somesite.com' + long stretch of arguments)

would be creating an array "URL" where the first argument (0) is 
https://tokens.somesite.com" and the remainder are the stretch
of args.

${A[0]} is the syntax for a single array element.  If the subscript
is "@" (as in ${URL[@]}) it evaluates to all array elements.

jl

-- 
Jon H. LaBadie                  ubu at labadie.us




More information about the ubuntu-users mailing list