Reputation: 27
Is there a way to add the url you are using in curl to the output file? I have a url string with a variable and each record set that is found, I want to include the url in the output file. URL example i am using is http://history/[1980-2012]/[1-12]/[1-31].hist.htm
Upvotes: 0
Views: 371
Reputation: 10702
If you add -i to your command you'll get the HTTP headers in the output as well with "Location:" on the 2nd line being what you want.
For example, this command:
curl -i -o test.html http://google.com
Generates this output in a file:
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Wed, 07 Mar 2012 21:00:39 GMT
Expires: Fri, 06 Apr 2012 21:00:39 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
Upvotes: 2