4 ms·
I think his argument is valid, and thinking about curl as an analog to cat makes a lot of sense. Pipes are a powerful feature and it's good to support them so n
by NickPollard 12y ago
I think his argument is valid, and thinking about curl as an analog to cat makes a lot of sense. Pipes are a powerful feature and it's good to support them so nicely.
However, just as curl (in standard usage) is an analog to cat, I feel that wget (in standard usage) is an analog to cp, and whilst I certainly can copy files by doing 'cat a > b', semantically cp makes more sense.
Most of the time if I'm using curl or wget, I want to cp, not cat. I always get confused by curl and not being able to remember the command to just cp the file locally, so I tend to default to wget because it's easier to remember,
- Touche 12y agoI find that weird. Why are you wanting to copy stuff from http all of the time? I only ever rarely do that because I want to examine something like an API response further for an extended period of time. Usually I just want to see the response once, or view the headers.
- scintill76 12y agoA common use for wget for me is downloading a tarball or something to a remote server. Browse for it on local browser, then type wget and paste the download URL into an ssh connection. It is a bit biased toward wget just because I happened to learn it first, but I could use curl -O the same way.
- Tyr42 12y agoCould also do `curl ${url}.tgz | tar xz`.
- coryrc 12y agoWhich fails badly if the download gets interrupted.
- scintill76 12y agoYeah, and you can't check file integrity (hash or crypto signature) first, or list the contents of the file before extracting.
- viraptor 12y agoNot the parent, but as another data point for you: my history | grep wget contains: a movie, certificates bundle, zipball from github, DTD document from ncbi, GeoIP country list, some script from github, composer.phar, qemu source, some gist, steam deb, ... So basically "stuff". I download "stuff" when needed ;)
- pessimizer 12y agoPeople aren't lying to you when they say that they spend a lot of time on the command line:) Also - how else (other than wget) do you download something to some remote server somewhere?
- willvarfar 12y ago> (other than wget) Curl? :p
- pessimizer 12y agoAren't we talking about curl?
- pessimizer 12y agoFor people who have difficulty with reading: If you aren't downloading things with curl (which is the entire subject of the thread), how else (other than wget) would you download things to a remote server? No need to answer, just helping out the non-native speakers in the thread.
- Tiksi 12y agoYou could always use netcat: echo "GET / HTTP/1.1 Host: news.ycombinator.com "|nc news.ycombinator.com 80 >yc
- barrkel 12y agoI don't use wget for testing APIs. I use wget for long-running downloads when I need to be able to continue later, for simple mirroring, and for bootstrapping web scraping scripts. In fact, the combination of wget -i (url-file) -k and egrep can be enough for many simple web scraping needs. The -k is really handy - converting relative links to absolute links. If I must use curl, I generally bootstrap it with "Copy as cURL" in the network tab of a browser's developer tools. But it's just not needed very often.
- coldtea 12y ago>I find that weird. Why are you wanting to copy stuff from http all of the time? This kind of question (and the other question you make above) remind me of the people that answer Stack Overflow questions with their opinions of "best practices" and "what you should be doing instead" instead of answering what the poster asks. E.g: Q. "How do I store JSON in mysql?" A. "Why do you ask? What do you want to achieve with this? You'll be better served with a NoSQL database". etc, etc.
- LeonidasXIV 12y agoI actually like this, because posters often have XY-problems. Especially if the solution the poster wants seems strange if often makes sense to question and propose a more sane solution to the whole problem he is actually having.
- Morgawr 12y agoThat is called the XY problem[0]. It is a fairly common practice especially in technical IRC channels. Honestly, it can be very frustrating but a lot of times it is useful and actually helps both the person asking the (wrong) question and the group of people trying to provide a proper answer. Some (maybe most?) people do take it too far and even refuse giving you a straightforward answer just to be pedantic and annoying. Those types of people have made this much of a bigger problem than it actually is, however thinking about the XY problem before you ask a question is always a good idea, regardless. [0] - http://mywiki.wooledge.org/XyProblem http://mywiki.wooledge.org/XyProblem
- Touche 12y agoThat's not what I was doing at all. My use of curl/wget is much different so I was curious of what they use cases are.
- a3n 12y agoAh, I was trying to figure out how to express my view of wget and curl as different tools, and you've done exactly that, thanks. Yes, I think of wget more like cp, and I think of curl more like cat, and there are times when I want exactly curl as cat, as opposed to wget as cp. Different tools, I like them both, and I use them differently. And, I only scratch the surface of capability for both tools.
- needusername 12y agoPipes (like much of UNIX) are stuck in ASCII. The response encoding has no relationship to your UNIX locale. The response would know the encoding but can't pass it on to the pipe because it's a concept from the 70ies. In the end all of this only works as long as everybody keeps to ASCII.