I have a script, which will parse an array like:
#!/bin/bash
URLs=(
...
"https://www.example.com"
"https://www.example.com/contact"
);
for URL in ${URLs[*]} ; ...
Now what I'm trying to do is to outsource the URLs
array into another file, pass that file as $1
and source it (source $1
) into my script. Unfortunately URLs
stays empty.
This is the file with the outsourced URLs array, which I'm trying to pass:
#!/bin/bash
URLs=(
...
"https://www.example.com"
"https://www.example.com/contact"
);
I'm calling the script like this:
./original.sh /absolute/path/to/array.sh
And, of course the original.sh
:
#!/bin/bash
source $1;
for URL in ${URLs[*]} ; ...
# e.g. curl ${URL}
# Tried also:
for URL in ${URLs[@]} ; ...
The idea is that I have different lists/files with URLs, which need to be passed to one single script in order to be parsed. Does anyone has an idea how I could do that?
"${URLs[@]}"
. See this – pLumo Apr 05 '19 at 11:55URLs
is kept? If you trigger it in the same file, it works for me, too. – manifestor Apr 05 '19 at 11:57#!/bin/bash
and is followed by the array declarationURLs=( ... );
. – manifestor Apr 05 '19 at 12:03