Database Reference
In-Depth Information
This eBook is for the use of anyone anywhere at no cost and with almost
no restrictions whatsoever. You may copy it, give it away or re-use
it under the terms of the Project Gutenberg License included with this
eBook or online at www.gutenberg.net
By default, curl outputs a progress meter that shows the download rate and the
expected time of completion. If you are piping the output directly to another
command-line tool, such as head , be sure to specify the -s option, which stands for
silent , so that the progress meter is disabled. Compare, for example, the output with
the following command:
$ curl http://www.gutenberg.org/cache/epub/76/pg76.txt | head -n 10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:--
The Project Gutenberg EBook of Adventures of Huckleberry Finn, Complete
by Mark Twain (Samuel Clemens)
This eBook is for the use of anyone anywhere at no cost and with almost
no restrictions whatsoever. You may copy it, give it away or re-use
it under the terms of the Project Gutenberg License included with this
eBook or online at www.gutenberg.net
Note that the output of the second command, where we do not disable the progress
meter, contains the unwanted text and even an error message. If you save the data to a
file, then you do not need to necessarily specify the -s option:
$ curl http://www.gutenberg.org/cache/epub/76/pg76.txt > data/finn.txt
You can also save the data by explicitly specifying the output file with the -o option:
$ curl -s http://www.gutenberg.org/cache/epub/76/pg76.txt -o data/finn.txt
When downloading data from the Internet, the URL will most likely use the protocols
HTTP or HTTPS. To download from an FTP server, which stands for File Transfer
Protocol , you use curl in exactly the same way. When the URL is password protected,
you can specify a username and a password as follows:
$ curl -u username:password ftp://host/file
If the specified URL is a directory, curl will list the contents of that directory.
When you access a shortened URL, such as the ones that start with http://bit.ly/ or
http://t.co/ , your browser automatically redirects you to the correct location. With
curl , however, you need to specify the -L or --location option in order to be redi‐
rected:
$ curl -L j.mp/locatbbar
If you do not specify the -L or --location option, you may get something like:
Search WWH ::




Custom Search