Wget is an extremely handy utility I use all the time when I find myself on a Linux box. It’s quite helpful, for example, for downloading files. Need to install Ruby? No problem, just download the binary like so:

wget example of downloading Ruby binary
<span class='line-number'>1</span>
<code class='bash'><span class='line'>wget <a href="https://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz">https://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz</a>
</span>

and you’re one step closer. There’s no flags to remember either.

Wget, however, isn’t natively available on OSX. From time to time, I’m stung to see the nefarious ‘command not found’ message after expectantly waiting to see some file I need downloaded.

Luckily, you can force cURL to act like Wget with a few flags. Simply use the -OL flags like so:

cURL acting like Wget
<span class='line-number'>1</span>
<code class='bash'><span class='line'>curl -OL <a href="https://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz">https://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz</a>
</span>

and you’ll be on your way to downloading some file.

Of course, it’s possible to get wget on your Mac via MacPorts or Homebrew; nevertheless, knowing you can achieve the same goals with cURL is always handy.

andrew_glover

When Andrew Glover isn't listening to “Funkytown” or “Le Freak” he enjoys speaking on the No Fluff Just Stuff Tour. He also writes articles for multiple online publications including IBM's developerWorks and O'Reilly’s ONJava and ONLamp portals. Andrew is also the co-author of Java Testing Patterns, which was published by Wiley in September 2004; Addison-Wesley’s Continuous Integration; and Manning’s Groovy in Action.

More from this author