curl command in linux with examples

curl command in linux (Fedora/Centos/RHEL) with examples

"

curl is a command line tool which is used to download the data from a server or transfer the data to serer using any of the supported protocols (HTTP, HTTPS, FTP etc..).

Syntax

curl [options...] <url>

curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP).

curl command works without user interaction.

curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more.

$ curl -O http://test/images/guest_os.qcow2
  % Total	% Received % Xferd  Average Speed   Time	Time 	Time  Current
                             	Dload  Upload   Total   Spent	Left  Speed
100  656M  100  656M	0 	0  23.4M  	0  0:00:27  0:00:27 --:--:-- 23.6M

curl command options

-O, --remote-name

Command output to a local file named like the remote file we get, Only the file part of the remote file is used and the path is removed.

-R, --remote-time

Makes the curl attempt to figure out the timestamp of the remote file.

-S, --show-error

Displays an error message if it fails.

-s, --silent

Don't show progress meter or error messages.

-f, --fail

(HTTP) Fail silently (no output at all) on server errors.

-#, --progress-bar

This progress bar draws a single line of '#' characters across the screen and shows a percentage if the transfer size is known

$ curl -# -O http://test/images/guest_os.qcow2
###################################################################################################################################################################### 100.0%


URL syntax is protocol-dependent.

we can specify multiple URLs or parts of URLs by writing part sets within braces '{}'.

http://test.{one,two,three}.com

We can get sequences of alphanumeric series by using [].

ftp://ftp.test.com/file[1-100].txt

with leading zeros)
ftp://ftp.test.com/file[001-100].txt

ftp://ftp.test.com/file[a-z].txt

Nested sequences are not supported, but we can use several ones next to each other.

We can specify any amount of URLs on the command line and will be fetched in the specified order.

We can specify command line options and URLs mixed in any order.

http://test.com/archive[1996-1999]/vol[1-4]/part{a,b,c}.html

We can specify a step counter for the ranges to get every Nth number or letter

http://test.com/file[1-100:10].txt

http://test.com/file[a-z:2].txt
"


Python installation

Privacy Policy  |  Copyrightcopyright symbol2020 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^