Almost there! There should be no problem using a for loop over the output of the cat command in this case (if I'm not wrong, the URLs cannot contain blank spaces) but in general I prefer the while read construct to correctly manage blank spaces, if any:
Code:
#!/bin/bash
i=1
while read url
do
/usr/bin/wget -O file.$i.wmv -c --load-cookies /cookies.txt "$url"
((i++))
done < $1
In bash you can use the
arithmetic operator to increment the i counter. The syntax i++ is inherited from the C language and
means increment the current value of the variable by one. There is a similar ++i (with the plus signs before the variable name, but I spare you the details right now).
In addition, if you want to pad the number with zeros (useful if you have more than 9 files and you want to see them sorted correctly in a list) you can try the printf statement as in
Code:
/usr/bin/wget -O file.$(printf "%02d" $i).wmv -c --load-cookies /cookies.txt "$url"
Hope this helps.