Hi guys
I'm trying to loop over the values of a file (or multiple files) passed as a parameter to the script as in, ./myscript file1 file2 ...
but awk
only recognizes the first line of each file.
#!/bin/bash
while [[ ${#} > 0 ]]
do
for archivo in ${@}
do
read url filename <<<$(awk -F',' '{print $1, $2}' $archivo)
curl -o $filename $url
done
done
Files passed as params to the script have the following structure:
url1,filename1
url2,filename2
...
The goal is, whenever the script is called with one or more parameters, awk
should parse (and pass) the urls and filenames contained inside each file to curl
for it to download the files listed.
Any suggestions on how to make it work?
Thanks in advance and happy day!
,
separator to a whitespace one - why not simply set the shell'sIFS
to,
and read the 2 fields directly?cat
?