[Linux](EN) Download file or resource using curl command

Download resources(files or web pages) by using curl command.


Environment and Prerequisite

  • Linux base system
  • Bash shell(/bin/bash)
  • Usage of curl command


About curl command

  • curl : It stands for Client URL. It is a tool to transfer data from or to a server, using one of the supported protocols
  • The command is designed to work without user interaction. It supports many protocols and methods also with many options.
  • Supported Protocols : DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP and ETC.


Download resource using curl command

(Method 1) Use -o or –output option

  • These options only support download to current working directory.
curl [URL] -o [RESOURCE_NAME]

or

curl [URL] --output [RESOURCE_NAME]


(Method 2) Use redirection

  • You can download resource to any directory.
curl [URL] > [RESOURCE_NAME_WITH_PATH]


Example : Download cirros image using curl command

Requirements


(Method 1) Use -o or –output option

  • Download file
curl https://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img -o cirros-0.4.0-x86_64-disk.img
  • Check MD5 hash value
  • MD5 hash value could be different depends on OS.
$ md5sum cirros-0.4.0-x86_64-disk.img
443b7623e27ecf03dc9e01ee93f67afe  cirros-0.4.0-x86_64-disk.img


(Method 2) Use redirection

  • Download file
curl https://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img > /home/twpower/test/cirros-0.4.0-x86_64-disk.img
  • Check MD5 hash value
  • MD5 hash value could be different depends on OS.
$ md5sum /home/twpower/test/cirros-0.4.0-x86_64-disk.img
443b7623e27ecf03dc9e01ee93f67afe


Reference

[Docker] 도커(Docker) 이미지 이름과 태그 목록 가져오기

> 도커(Docker) 이미지 이름과 태그 목록을 awk과 tail 명령어를 이용해 가져오는 방법을 알아보자## 환경- Linux 기반 시스템- Bash shell(/bin/bash)- Docker- awk, tail 명령어## 도커(Docker...… Continue reading