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.
Or, Bash on Ubuntu on Windows -> wget :D
Yes... that works too :D
thatt the easiest cmd in windows
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.
@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.where does the downloaded file go???
It goes in your current folder. Use -O to specify where you want it to go.
files is downloaded but cant find it
@James Make sure you use
-Oand give it a path.To download it in the current folder do this:
why wouldnt you just
$curl url >drive\folder\file.extHi @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.
Thanks for the information. It really works.
After what seems like it completes the download it says, "curl: (3) Port number ended with '\'"
File is not in the output location.
GOOD!
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
need help in programming with the back end information my mail is lesliegim1 @gmail.com
Oddly enough, I first read and saved that article on 2019-10-14, stumbled upon it again a few days ago while trying to sort a bit of the mess I accumulate every year (I'm satisfied when the number of unsorted files for a given year is below 10,000 – for year 2019 I managed to go from 21,638 to 8,987), and right now I'm trying to solve a downloading issue, which brought me back to that same article which I thoroughly re-read... So I tested, on Windows 7: indeed a "curl" command in PowerShell does not behave like the regular curl (as in the basic shell command prompt AKA cmd.exe), but with "curl.exe" it does invoke the actual curl executable with the regular behaviour I'm accustomed to (provided that the curl.exe file is somewhere among system folders). With "curl" only, the specific curl parameters are not recognized, and a message is very briefly shown at the top of the PowerShell window during the download, saying "Writing web request / Writing request stream... (Number of bytes written: ######)". With "curl.exe", all curl parameters are recognized, and it displays more information, below the command and persisting after the download: total size, average speed, % received and so on. Also, with "curl.exe", "-O" (capital O) stands for "--remote-name", which means that it automatically names the downloaded file after its name on the server, whereas "-o" is used to specify a name.
It doesn't solve my issue which is: how come the link below (and likewise all image links from the same website) fetched with Firefox yields a 333KB JPEG file (with a JPEG compression parameter of 90 according to IrfanView), whereas the very same link fetched with curl yields a 212KB JPEG file (with a JPEG compression parameter of 82, therefore slightly lesser quality). And PowerShell "curl" (or "Invoke-WebRequest") yields the same file as the actual curl program. I tried many parameters, to no avail.
(Mildly NSFW... but still mindblowing... you gotta wonder how she can carry all that weight with such a small waist and be smiling nonetheless...)
Hi Gabriel. Thanks for writing, I may need to update this article since it is aging. However, I found your issue an interesting challenge, so I dug into it.
Turns out, it's not a bug, it's a feature. The image you shared is hosted on cloudflare, and if you check the Content-Type on the response, you might be surprised. On firefox, you are getting a jpeg returned. On Chrome, you would get a webp file, which tend to be smaller (140kb) in my case.
Cloudflare supports serving different format or quality images based on the "Accept" header. You could manipulate the header for different results.
Also, I hope you didn't edit this image in the vibecoded version of photoshop lol.
Join the Conversation