As a Linux user, I can't help but spend most of my time on the command line. Not that the GUI is not efficient, but there are things that are simply faster to do with the keyboard.
Think about copy and paste. Select a text you want to copy, go to the edit menu, click, precisely move down to copy, click, then go to the destination, click where you want to paste, go to edit menu, click, move down to the paste option, then paste. Every time I see someone do this, I die a little inside. Sure you can save some time by right-clicking, copy, right-click, paste. But you can save some more time by pressing, ctrl-c then ctrl-v
My hands are already on the keyboard, and I would rather do the mundane things on the keyboard and not think about them.
One thing I do frequently is download files. They can be zip file, tgz, or jpg. On linux, all I have to do is open the command line, run wget with the file I want to download and it is done.
wget http://example.org/picture.jpg
Straight to the point. But how do you do that when you are on a Windows machine? Let me introduce you to cURL, pronounced curl. (i don't know why I wrote it the way I did)
curl is a very powerful tool with too many feature. But I just want to download the file on Windows so let's just learn how to do that.
Open PowerShell. That's Windows Key + R
then type powershell and press enter.
Now run the curl command with the -O
option to specify the file output.
curl http://example.org/picture.jpg -O picture.jpg
Easy right? Now you can download files right from the command line all by simply using your keyboard.
OK. It is time I confess. This is not the curl tool you are using. It's only an alias. In reality, we are calling the command Invoke-WebRequest
. But hey! It works, so we don't care. You can call it in its native format if you want to.
Invoke-WebRequest http://example.org/picture.jpg -O picture.jpg
Either way, now you know how to download a file from the command line.
Comments(16)
Andy :
Or, Bash on Ubuntu on Windows -> wget :D
Ibrahim :
Yes... that works too :D
shrinivasalvanjdk :
thatt the easiest cmd in windows
Manish :
I'm able to download the file using the command "Invoke-WebRequest http://example.org/picture.jpg -O picture.jpg", but the file size is reduced.
Ibrahima Diallo :
@Manish I just tested it by downloading a jpeg file with curl, wget, and Invoke-WebRequest and the sizes are all the same. There is no extra compression with
Invoke-WebRequest
, all it does is download the file as is.sd,vns :
where does the downloaded file go???
Ibrahim :
It goes in your current folder. Use -O to specify where you want it to go.
james :
files is downloaded but cant find it
Ibrahim :
@James Make sure you use
-O
and give it a path.To download it in the current folder do this:
Joel :
why wouldnt you just
$curl url >drive\folder\file.ext
Ibrahim :
Hi @Joel
Thanks for your comment. curl was added windows after this article was written in Windows 10 Build 1803.
I'll update the article to add it as an option.
Shivani :
Thanks for the information. It really works.
Sam :
After what seems like it completes the download it says, "curl: (3) Port number ended with '\'"
File is not in the output location.
liam :
GOOD!
Jonh Melo :
I need a downloader code to include in my site. But I do not wantto use the Lownload from Wndows, that dont work in some browsers. Will be goodif in Java. Thanks. John
ben :
need help in programming with the back end information my mail is lesliegim1 @gmail.com
Let's hear your thoughts