Peter Wong
Peter Wong

Reputation: 33

curl: (3) Illegal characters found in URL with bash shell

I want to get the random page from wiki and paste it on txt file.

curl -I https://en.wikipedia.org/wiki/Special:Random|grep -E "Location:"|cut -d ' ' -f2 > "result.txt"

But when I retrieve it from txt file and it come out the error.

cat result.txt| xargs -I % curl %

Upvotes: 0

Views: 3943

Answers (1)

Martin Tournoij
Martin Tournoij

Reputation: 27822

How about just following redirects with curl by adding the -L switch? No need to parse the Location header:

curl -L https://en.wikipedia.org/wiki/Special:Random

Upvotes: 1

Related Questions