for name in $( cat test.html | grep -Eo "<a href=\".*pdf\">" | sed -r 's/<a href=\"(.*pdf)\">/\1/g' ) # for name in $( cat test.html | sed -r 's/<a href=\"(.*pdf)\">/\1/g' ) # for name in $( sed -r 's/<a href=\"(.*pdf)\">/\1/g' test.html ) do echo https://www.raspberrypi.org/magpi-issues/$name >> '1.txt' echo -e "\tdir=./Magpi" >> '1.txt' echo -e "\tout=$name" >> '1.txt' done