4 ms·
That's the reason I use wget and only when necessary I switch to curl. It's not that I wouldn't forget about that nasty behaviour (eventhough I sometimes do for
by yason 12y ago
That's the reason I use wget and only when necessary I switch to curl. It's not that I wouldn't forget about that nasty behaviour (eventhough I sometimes do forget) but it usually goes like this:
$ curl -o news.ycombinator.com
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
$ curl -O news.ycombinator.com
curl: Remote file name has no length!
curl: try 'curl --help' or 'curl --manual' for more information
$ curl -O foo news.ycombinator.com
curl: Remote file name has no length!
curl: try 'curl --help' or 'curl --manual' for more information
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
$ wget news.ycombinator.com
--2014-11-17 14:27:18-- http://news.ycombinator.com/
Resolving news.ycombinator.com (news.ycombinator.com)... 198.41.191.47, 198.41.190.47
Connecting to news.ycombinator.com (news.ycombinator.com)|198.41.191.47|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://news.ycombinator.com/ [following]
--2014-11-17 14:27:19-- https://news.ycombinator.com/
Connecting to news.ycombinator.com (news.ycombinator.com)|198.41.191.47|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’
[ <=> ] 22,353 --.-K/s in 0.07s
2014-11-17 14:27:19 (331 KB/s) - ‘index.html’ saved [22353]
With wget, I can just through any URL to it and it‘ll probably do the right thing with the least amount of surprises. „Grab a file“ is my usecase 99.99% of the time, „Print a file“ is the rest 0.01%.
- Touche 12y agoI asked this of someone else, just out of curiosity, why do you find yourself downloading content from http that often? What are you doing with these files?
- dec0dedab0de 12y agoOn my laptop, to view something while offline. On a server, to install something that is not in a package manager.
- deleted 12y ago[deleted]
- noselasd 12y agoOn that note, sites that don't easily offer copyable links for download annoys me to no end. Most of the time downloading anything, I need it on another machine, and normally the easiest way is copy/pasting an URL from my local web browser to a remote terminal, and fetch it using wget. In which case an auto redirect to a mirror selector that again auto downloads the item, all handled by javascript, is pretty frustrating.
- Igglyboo 12y agoI noticed this with mega.co.nz and I hate it, they do all the downloading with javascript then start an actual browser download (which is just copying from localstorage to your download directory) which finishes in an instant but I have to remain on the page now.
- TylerE 12y agoWith Mega it's rather unavoidable as the javascript is running the decryption.
- cooper12 12y agoI don't think it would be possible to use curl for mega because it has to locally decrypt the stream first. I do remember using a (now deprecated) python library that wrapped the mega api [0] a while ago, so that might interest you if you want to do everything from the command line. [0] https://github.com/richardasaurus/mega.py https://github.com/richardasaurus/mega.py
- fragmede 12y agoThere's a fix for that! Firefox has: https://addons.mozilla.org/en-US/firefox/addon/cliget/ https://addons.mozilla.org/en-US/firefox/addon/cliget/ and it's sorta built-in on chrome: https://coderwall.com/p/-fdgoq/chrome-developer-tools-adds-copy-as-curl https://coderwall.com/p/-fdgoq/chrome-developer-tools-adds-c...
- digitalsushi 12y agoCurrent versions of the chrome debugger (and maybe others!) will let you print out the curl command to retrieve a resource that is completely inaccessible in the web interface. If you keep a little media server like plex, et al, it's a really convenient tool for time shifting/stealing/whatever the word is some video on a website that won't let you at the video source. You just open the debugger, view the network resources, click play, sort by size, right click the one that is growing (the video), get the curl, paste it into a terminal with a -o flag, and now you have the video. Whether you should have it is another thread, not this one.
- adamtj 12y agoIt sounds like maybe you are most familiar with GUIs or the web. Curl is a UNIX tool and doesn't work like those things. If it's the only unix tool you use, that might seem jarring. Of course it would be a smoother experience for you if it worked more like the rest of the tools you are familiar with, but changing it would be a mistake. If curl were changed, then it would be one of the few unix tools that differs from the rest. That would make it jarring to people who use unix. Nobody wants to erode the good parts of unix and destroy the unix way just to make some commands slightly less jarring to people who don't regularly use unix. Especially when you don't even need curl. That's the wrong option for you. Right next to the option in Chrome to copy a curl command is the option to copy just the url. Just use that and paste the url into your browser, which will work more like you'd expect. If you must use curl, you almost certainly don't want to use "-o". That's an advanced option for when you are downloading multiple resources with a single command. You use it to provide a template for the multiple output filenames necessary in that particular situation. If you only want to specify a single filename, then do like you would with any other typical unix command and redirect the output to a file. For example, append ">filename.html" to the end of the command. Unix tools rarely have options to specify output filenames. They are as unnecessary as a button in a web browser that will let you "Display this webpage." Displaying webpages is what a web browser does, and writing output to a file is what a unix command does. It's just that the default file for a unix command is your terminal. Your shell makes it dead simple to pick a different one if that's what you want.
- simias 12y agoI use wget a lot. I don't use a desktop manager and I generally don't trust my web browser to do The Right Thing when I download various non-html files. I prefer using the command line so I always "Copy Link Adress" and then do whatever I want with it. For instance when I download some archive I don't have to bother selecting where to download the file from the GUI (I hate navigating filesystems from GUIs), waiting for it to finish before switching to the command line to extract it. I just get the address, "curl $link | tar xzv" and I'm done.
- ANTSANTS 12y agoI used to deal with shitty, unreliable internet all of the time (oh wait, I still do, I have TWC...), so wget was really useful for ensuring that I could keep documentation and other reading material handy when I inevitably lost my connection. Point it at the base URL, tell it to recursively download the whole thing, and within minutes you've got a complete mirror of the static site of your choosing, with the URLs patched up to point to local content and everything.
- clarry 12y agoAll the browsers I've tried have a shitty UI. It's faster for me to copy-pasta an URL into the terminal than it is for me to wait for the stupid download dialog to pop up, click save as, then use that silly widget to navigate to the path I likely already have as the cwd in my shell.
- randallsquared 12y agoI often play around with new languages and other software that isn't in my distro's repo. For that, when they have a .deb available, it's often downloadable, and if I'm just playing around, I don't want to mess with my sources. So I copy the URL in my browser on my local machine, and paste it after "wget " in my terminal on the server, and go from there. I could obviously just use curl for this, but wget requires no additional options or thought.
- mahouse 12y agoI have a bad connection, so it's better for me to use a download manager that can resume failed downloads properly. Browsers usually fail at that.
- fragmede 12y agoYou must understand that I live and breath in the terminal. If I'm working, my computer has at least one terminal window open. When I'm in the middle of projects, there are several terminals, all on different 'machines' (ssh/chroot/and now docker) in different directories, and I need a file, be it source code or a binary or an rpm/deb/tgz/zip or just plain data to be where I am right now. I might use scp for this purpose, I might use rsync if the connection is flakey. Some times there's a shared file server and I can just use 'cp' instead. Http is just yet another protocol where files come from, and when I use curl/wget I don't want the file in ~/Downloads along with all the other random crap, I want that it downloaded to where my terminal window is pointed, which may be a machine half-way around the world from me, or at the very least, in the right directory. It doesn't make sense to download it to my machine, then upload it to where it needs to go either - just wget it directly, on the machine it needs to be on, in the directory where it needs to go.
- jenscow 12y agoWell, I find curl easier to type: curl www.example.com | ... wget -O - www.example.com | ... I guess it depends on what you're trying to achieve.
- jeena 12y agoI never know what wget will use as the file name so I only use it if the resource has a real name, if it is only like in your example I would always prefer: curl https://news.ycombinator.com https://news.ycombinator.com > hn.html That way I am sure I don't overwrite some other file I already have in this folder with the same name which wget will give it.
- cooper12 12y agowget won't overwrite files by default. Instead it will append .1 to the filename and so forth. You'd have to use the -c/--continue option.
- vacri 12y agoYou appear to be complaining that curl shows you exactly what's at a URL ('cat url'), and that wget is better for fetching an object served by that location. To me, those are the use cases. They're both fire-and-forget cli tools; it's not like you have to mentally invest in one over the other like vim and emacs. Just use both as required.
- cooper12 12y agoWhat always bugged me is that curl doesn't follow redirects by default. Instead you have to pass it the -L option. curl always made more sense to me as a programmer's tool. It seems to be made for those who want a tool that you have to predictably guide step-by-step rather than something that tries to be smart and uses sane defaults. That's not to say it doesn't have it's uses though.