Sample Header Ad - 728x90

Using Bash to split XML data into variables

5 votes
4 answers
11532 views
I am trying to download some files from a services. The files are found in an XML file. The XML file can have a single file or several files to download. However, now I have a problem with my script. I do not know how to split string from XMLLINT into array so that I can download each file individually. I need to split the string into several variables and then download each file of the URL string. However the file 201701_1 do not repeat and hence, I download them using curl without any problems. But the files coverage.zip repeat and they become overwritten by curl. I do: Then I do curl to download individual files. curl -O -b cookie $URL At the moment, my script is as follows: while read edition; do XML=" https://google.com/411/201701_01_01.zip https://google.com/411/201701_01_02.zip " URL=$(echo $XML | xmllint --xpath \ "/*[name()='download-area']/*[name()='files']/*[name()='file']/*[name()='url']/text()" -) echo "URL:: " $URL done < $LATEST_EDITION LATEST_EDITION is a simply a file with lines. My question is:: How can I split VAR_1 and VAR_2 into several URLs so that I can download them individually? How can I prevent coverage.zip from being overwritten?
Asked by Noel Alex Makumuli (141 rep)
Nov 20, 2017, 07:22 AM
Last activity: Nov 21, 2017, 01:48 AM