What does this do in bash: [@]?
Little Girl
littlergirl at gmail.com
Fri Jul 29 18:43:12 UTC 2022
Hey there,
Bo Berglund wrote:
>Little Girl wrote:
>>https://unix.stackexchange.com/questions/135010/what-is-the-difference-between-and-when-referencing-bash-array-values
>So do I get it right?:
>- Something gets stuffed into a bash variable like URL in the example
>- When this variable is later used as the argument to curl then
>using [@] as shown makes the arguments in $URL load separately into
>curl as a list of different arguments
I don't think so. At least, I wasn't able to get it to separate the
characters in one continuous string into separate items.
>But if the content of $URL is a long stretch of arguments separated
>by spaces, what is then the need for [@]???
I'm not sure. In the example on that Stack Exchange page, the spaces
in the string value of that LIST variable were used by [@] to
distinguish the separate items.
I suspect the site you'll be using the command on will be feeding you
a space-separated list or an associative array of URLs and the [@]
part of the curl command will make it parse them one by one.
[aside]
Check out the very cool example of it being used with
an associative array here:
https://stackoverflow.com/questions/8880603/loop-through-an-array-of-strings-in-bash
[/aside]
This is out of my element, though. I'm more of a Python person, but
this is interesting, so I figured I'd jump in. Now I have to go find
out if I can make this happen in Python.
--
Little Girl
There is no spoon.
More information about the ubuntu-users
mailing list