csv - Bash: curl: illegal characters in URL -


i have file containing column of urls, read using following bash script:

while read line         result=`curl $line -i | grep http/1.1` # save curl result         printf '%s,%s\n' $line $result >> output.csv  done < $input_file 

when run script, got error: curl: (3) illegal characters found in url.

an example of urls this: http://stackoverflow.com/

i'm not sure if resolved issue here answer based on comment:

replace result='curl $line -i | grep http/1.1'

with: result=$(curl $line -i | grep http/1.1)

to on safe side put grep text inside qoutes , use variable this:

result=$(curl ${line} -i | grep "http/1.1") 

Comments