How do you:
- read from a text file
- split each line with a comma
- and assign it to variables in bash?
filelist
renamedfile.xml,url-01.php
renamedFileDifferent.xml,url-02.php
specificFileRename.xml,”url-03″
newFilename.xml,”url-04″
I’m looking to accomplish something like this:
#!/usr/bin/env bash
while read line
do
wget -c -O newfile remoteFile >/dev/null 2>&1
done < filelist
Also, what is a typical place to place shell files for cron jobs?
By setting the special IFS variable (internal field seperator), you can cause bash to split on commas instead of the default tab, newline, and space.
The quotes in your sample file will have a problem with this. You can use a parameter expansion to strip the quotes.
If the quotes are actually intended to be part of the filename, then it will need to be url encoded. You can use a parameter expansion for this as well.