0

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 %
2
  • What's the content of your result.txt file? Which shell do you use? Why do you use xargs -I %. Have you tried xargs --verbose? Commented Mar 21, 2016 at 11:43
  • The content show the random url from wiki Commented Mar 21, 2016 at 11:45

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.