Terminal Lesson 20
Hey guys, isn't that kids?
And one with terminal lesson 20. This terminal lesson, I'm going to show you how to download web pages onto your computer from terminal, such as Google's index page that downloaded to this simple text file on my desktop.
Hi, I open it with Taco HTML in it. You can clearly see that it is Google’s homepage.
How do I do this with terminal? I'll go to terminal, and there's a very interesting command that downloads the file from the internet. Now, you may know about wget
on Linux, which downloads the file; this works pretty much like that. You take curl
space -O
space and then the URL.
So, I'll do www.google.com
, and by default, it will just display the text of the webpage.
Watch. Now, say you want to download it to a file. All you do is curl -O http://www.google.com
, and this time let's do >
after s
, another space, then the filepath ~/desktop/file
.
Here we go! Now, if I say vi ~/desktop/file
, it is Google’s homepage.
So, that is how to download a web page from the internet. Now, the cool thing is that you could run commands that you put on your website.
So, say you have a website mattkidsandall.com/script
, you could have a shell script that runs in the background that every minute keeps on re-downloading that script and running it.
So that way, whenever you change that script on your website, everyone who has this little program running gets this new script. So you could really make something that lets you control a lot of people's computers with this.
So, anyway, this is just ultimately a great way to not use wget
because Mac doesn't support wget
. Like, if I typed wget
, I think you can install it from any more Linux repository; it's just sitting there.
But curl
is a pretty nice way to do this. So, I hope you try curl
out.
Um, I hope you start using it. Like, it's annoying—whatever. I find a zip file, and Safari automatically unzips and stuff. I wanted to just be able to download it, zip it, to see what files are in it and then finally get it.
So, this is how to use curl
. This is terminal lesson 20. curl
has many more options, like -I
, I think it’s like -1
, -2
, but they aren't HTTP options, and more like FTP, SMB, stuff like that.
But this is how to do it. So, I know a lot of people have been asking me this a lot, and I'm glad I figured it out.
So, anyway, thanks for watching, my kids and the one. Subscribe and goodbye.