Skip to content

Instantly share code, notes, and snippets.

@aucker
Created August 26, 2022 01:34
Show Gist options
  • Save aucker/79681919883fe923d475879fc7c5cbc2 to your computer and use it in GitHub Desktop.
Save aucker/79681919883fe923d475879fc7c5cbc2 to your computer and use it in GitHub Desktop.
The curl and wget tools

Curl & Wget(●'◡'●)

Curl

Usually, I can curl through the link to get some info.

~ curl www.google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com.hk/url?sa=p&amp;hl=zh-CN&amp;pref=hkredirect&amp;pval=yes&amp;q=http://www.google.com.hk/&amp;ust=1661476334199167&amp;usg=AOvVaw1wvka0RbQuFDrG4bisPpRl">here</A>.
</BODY></HTML>

When downloading github files, just go to get the raw link, then

curl $link -o $filename

When downloading files, use the command:

➜  curl -LO https://go.dev/dl/go1.19.linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    73  100    73    0     0    159      0 --:--:-- --:--:-- --:--:--   159
100  141M  100  141M    0     0  5229k      0  0:00:27  0:00:27 --:--:-- 5225k

Wget

When downloading github files, just use the link, no need to get the raw link, then

wget $link

When downloading files, use the same way. Note: sometimes you need the sudo option

➜  wget https://go.dev/dl/go1.19.linux-amd64.tar.gz 
--2022-08-26 09:32:21--  https://go.dev/dl/go1.19.linux-amd64.tar.gz
Resolving go.dev (go.dev)... 216.239.32.21, 216.239.36.21, 216.239.38.21, ...
Connecting to go.dev (go.dev)|216.239.32.21|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.19.linux-amd64.tar.gz [following]
--2022-08-26 09:32:22--  https://dl.google.com/go/go1.19.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 114.250.65.33
Connecting to dl.google.com (dl.google.com)|114.250.65.33|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 148796421 (142M) [application/x-gzip]
Saving to: ‘go1.19.linux-amd64.tar.gz’

go1.19.linux-amd64.tar.gz                100%[==================================================================================>] 141.90M  4.78MB/s    in 26s     

2022-08-26 09:32:48 (5.41 MB/s) - ‘go1.19.linux-amd64.tar.gz’ saved [148796421/148796421]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment