Download A File Using Cygwin and cURL

By  on  

I'm starting to like using Cygwin more and more. Command line scripting allows me to get the information without all of the hassle. Why should I open Firefox, type in the address, deal with the ads, and click 5 links before I can get to what I want when I can use command line to download what I want? Here's how you can download a file using the cURL package from the command line.

The Bash Script

curl https://davidwalsh.name/ --O homepage.txt

The above example downloads my homepage and saves it into a file named homepage.txt. The file gets downloaded to the c:\cygwin\home\{user}\ folder. For fun, here's how to download Cygwin's setup file from Cygwin.

curl http://cygwin.com/setup.exe --O cygwin-setup.exe

Great stuff. What would you use this for?

Recent Features

  • By
    5 Awesome New Mozilla Technologies You’ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...

  • By
    CSS Gradients

    With CSS border-radius, I showed you how CSS can bridge the gap between design and development by adding rounded corners to elements.  CSS gradients are another step in that direction.  Now that CSS gradients are supported in Internet Explorer 8+, Firefox, Safari, and Chrome...

Incredible Demos

  • By
    Highlight Table Rows, Columns, and Cells Using MooTools 1.2.3

    Row highlighting and individual cell highlighting in tables is pretty simple in every browser that supports :hover on all elements (basically everything except IE6). Column highlighting is a bit more difficult. Luckily MooTools 1.2.3 makes the process easy. The XHTML A normal table. The cells...

  • By
    HTML5 download Attribute

    I tend to get caught up on the JavaScript side of the HTML5 revolution, and can you blame me?  HTML5 gives us awesome "big" stuff like WebSockets, Web Workers, History, Storage and little helpers like the Element classList collection.  There are, however, smaller features in...

Discussion

  1. I’ve used curl to download a ton of scanned documents from the Library of Congress. Each page was done as a separate TIF and after doing about 10 manually from the browser I learned from a friend about curl… Now if I had only been smart enough to handled getting both TIF and JPG at the same time…

  2. I typically use curl to download files onto my server rather than downloading to whatever machine I’m working on and then using FTP to copy it up. Particularly when I’m playing around with grabbing wordpress themes and things like that.

  3. You can use curl to create a super simple twitter client.

    For downloading files, I prefer wget.

    Full Disclosure: I use Linux – not Cygwin.

  4. If you play it right you can go check most everything you want with some fancy cURL-ing. Cygwin is the new iGoogle….

    @David: BTW… you get Ubuntu running? Let me know what you think.

    • Hasmik

      Hi. As I understand you use cygwin, am i right?…..So I ask you for help….I want to install cygwinn , but it isn’t complete so there are packages that cann’t be known in process of installing and postinstalling error occurs saying that these packeges ( for ex. brltty.sh exit cod1) aren’t known. what can I do. Please response if you can help. Thanks.

  5. @Eric: I’ll IM you about the Ubuntu. Trouble was afoot…

  6. Isn’t wget better :) ? Personally I prefer some unix platform, where these great tools are installed by default, bash is better than cmd etc. At the moment I’m using mac … Windows for web testing can run there through virtualization, that’s no problem …

  7. @Botanicus: Don’t ruin tomorrow’s post, Bot!

  8. Aloke

    AFAIK, both curl and wget use the same underlying libraries.

    Also, until wget added the new -s options, curl was the only way to retrieve https documents.

  9. Rad

    “Why should I open Firefox, type in the address, deal with the ads, and click 5 links before I can get to what I want when I can use command line to download what I want?”

    Because you don’t know the URL of every file that exists on the internet. Using these commands can be useful, but will never be able to replace a web browser for downloading files.

  10. How can use Cygwin to compile & build files ??

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!