Skip to main content

Wget & Curl

You will want to send requests to the Internet and/or network.

The two most common tools to do that are wget and curl.

Both of these are common to find in use so I'll take the time to show you both but they do relatively do the same thing. In general I'd suggest you stick to using curl; it's a more powerful tool that can do (almost) everything wget can.

Wget

wget works like cp but instead of copying a local file you're copying something off the net. So you'll identify a remote file (usually a URL) that you want to fetch and save to your local file system. So let's give that a shot.

Download the game from the github user

wget https://raw.githubusercontent.com/btholt/bash2048/master/bash2048.sh
chmod 700 bash2048.sh ## make it executable by adding the execute permission
. bash2048.sh ## run the game
unique thing wget can do compared to curl

It can redo recursive downloads.
So imagine there's a website out there that has a bunch of CSS and a bunch of JavaScript, and those things linked out to other files that link out to other files, right? And they're kind of like this web of files that go out.Wget will actually read through, find other URLs, and download those URLs as well, right? So you can actually recursively download entire websites using Wget,whereas curl does not have that capability. So whenever you need to do those sorts of like go grab me this entire website,Wget can do that for you.Otherwise I would say, 100% of the time just use curl, cool.

for more information try to put optional flag after the wget command

wget --help

Curl