34 comments

[ 0.23 ms ] story [ 85.0 ms ] thread

  curl -C - -O http://yourdomain.com/yourfile.tar.gz
Why the dash between the -C and -O?
From the man page. Use "-C -" to tell curl to automatically find out where/how to resume the transfer. It then uses the given output/input files to figure that out.
Correct me if I’m wrong, but usually “-“ is used (at least in my experience, which is strongly biased towards compilers) as an argument to signify input comes from standard in rather than a file.
That's generally true in my experience too, but in this case the parent is correct. Ctrl-F "--continue-at" [0].

[0] https://curl.haxx.se/docs/manpage.html

Yeah, I get that they're right. I just wanted to share my surprise that curl changes this "convention", though I guess it's to be expected because curl doesn't really take input anyways.
There is nothing particularly special about "-", but a lot of programs do use it for standard input like you said. e.g. awk, cat, diff. My macOS system has a quite a few of these

  grep -e '-.*standard input' /usr/share/man/man1/*
Working with Windows mainly it always amazes me how powerful the command line tools in Linux are. Most Windows programmers don't know much about command line so downloading some files is a huge affair. If you know curl it's just so easy.
(comment deleted)
That’s why I find it hard to convince people how annoying it is to use Windows for software development. It’s hard to miss what you aren’t aware of.
Funny, those of us who enjoy using Windows (esp. Visual Studio) for dev but are aware of how powerful command line tools are find it hard to convince you guys of the reverse in exactly the same way. We don't get the feeling you know what you're missing out on either. ;)
Is there a difference between Visual Studio's Windows and Linux versions?
Visual studio and visual studio code are two very different products. Visual studio doesn't even run on Linux.
Thanks for the explanation.
I think you could say Visual Studio Code is to Visual Studio as GIMP is to Adobe Photoshop? Decent, and still useful/handy, but honestly still not even a comparable substitute.
I spend half my waking hours staring at Xcode, so believe me, I do know when command line tools are lacking ;)
You should try Visual Studio, on Windows if you have to ;) it's not just CLI vs. GUI that I'm talking about, though that's of course a significant part of it too. Eclipse is a GUI too but I still find it painful. (w.r.t. Xcode I've only barely touched it, so hard to compare, but nothing particularly good or bad stood out to me in the little bit I used it.)
You just download nix tools for windows.
We are working hard to fix this. We ship Curl (and ssh and bsdtar) in Windows 10, and you can use WSL to run whatever Linux tools you want.
Make sure you start posting more sample code for these tools. Most windows devs are not aware of the command line or find it "unprofessional".
Yup, well aware of your team's efforts. I think it's a great step forward, and from the little I've used it I think it's pretty cool.
I really appreciate your work, it's made my day to day so much better.

You have a true once in a life time opportunity with how badly Apple is screwing the hardware pooch, if your hardware division could put out a laptop to rival the retina Macbook pro with up to date hardware and an excellent command line ecosystem you could very well shift an entire generation away from OsX.

Thanks for all the hard work I'm using Linux for windows right now.

> You have a true once in a life time opportunity with how badly Apple is screwing the hardware pooch, if your hardware division could put out a laptop to rival the retina Macbook pro with up to date hardware and an excellent command line ecosystem you could very well shift an entire generation away from OsX.

Surface?

(comment deleted)
As a Linux person that uses Windows on a daily basis, a few things have impressed me lately; Chocolatey[0], VS Code[1] especially w/ Azure integrations[2], and Windows Subsystem for Linux[3]. Things have come a long way....

[0] https://chocolatey.org/

[1] https://code.visualstudio.com/

[2] https://code.visualstudio.com/docs/azure/extensions

[3] https://docs.microsoft.com/en-us/windows/wsl/about

If you know about the Linux tools things aren't that bad with Windows. My complaint is that a lot of windows devs aren't aware of the command line and its power.
Having to occasionally work with Windows (or more accurately, support people using Windows for tasks that would much better be suited by Linux) makes me aghast at how bad its CLIs are at very basic interface things.

People who work extensively in Windows environments tell me that Powershell is very, well, powerful, and I'm sure it is for certain select use cases of interacting with Windows' internals. But it's baffling, however, how completely incapable it is of handling basic things like sane, well-explained escaping behavior.

I've attempted to find explanations for how people using Powershell should properly escape JSON (either for sending to HTTP APIs or for setting JSON environment variables when using Docker for Windows) and have concluded that it's basically impossible, as the escaping behavior is so different from *nix shells and appears to be documented nowhere.

Supporting it is further complicated by lack of readily available test environments: even if I wasn't running Linux myself, spinning up a VM is free because there's no software license. This isn't the case with OS X, but I can at least assume that OS X bash works the same as Linux bash for 99% of things. Powershell is completely alien and I know of no free way to try it--maybe Azure provides some variant on their free tier, but I haven't looked into it much (my overall experience trying out Azure was that it was a dumpster fire to be avoided at all costs unless you need cloud AD, in which case it's probably amazing).

> Powershell should properly escape JSON

You can escape things with `. So "{`"foo`": `"an \`"escaped \`" value`"}". Or because powershell has types and objects you can just use native objects and hashes, then pipe it to `ConvertTo-Json` when you need a string.[0]

> Powershell is completely alien and I know of no free way to try it

Powershell is opensource and cross-platform as of last year. [1] Though its still definitely windows first.

0: http://wahlnetwork.com/2016/02/18/using-powershell-arrays-an...

1: https://github.com/PowerShell/PowerShell

don't. use httpie ;p
httpie lacks a complete feature set in some cases, though day-to-day it's much nicer. I'll trade cURL's (admittedly clunky) --resolve, which is still necessary in some situations, for having native JSON pretty printing most of the time

I also like that it's Python and I can probably change something in its source more easily and quickly than I can with cURL.

`curl URL/File.tar.gz | tar xz`

Download and decompress in one go

A lot of services are using OAuth (or OAuth2) and I haven't been able to figure out how to use curl with such services. Can anyone point me at a good tutorial for using curl with Flickr in particular?
I would probably not reach for curl as my first tool to interact with OAuth v2 datasources. Flickr seems to have a wide variety of available libraries[0], and they also have API documentation. Is there a good reason to use curl rather than something else?

[0] https://www.flickr.com/services/api/

Curl is easily used in shell scripts.