14

I have tried googling for an answer for an hour now and still no luck. Does anyone know what this command mean?

wget -qO- 127.0.0.1

I know wget is the Linux "web get" utility, and 127.0.0.1 is localhost. I have no idea however what the -qO- mean?

I also believe the above is different to wget -q -O 127.0.0.1 as from a simple run in the terminal is giving me different result.

Note: I am trying to understand this command from this Vagrant - Getting Started Tutorial.

Many thanks in advance.

2
  • Actually, another google search on "wget qO" (without the dashes this time) gives me this forum that suggests the command means: print the HTML content (in this case 127.0.0.1) to the terminal screen. But where can I find out more about the -something- syntax? (i.e. a single dash on left and right of the option keyword).
    – Atlas7
    Aug 2, 2015 at 15:10
  • 3
    It looks like I haven't done my research thoroughtly enough. I just found this forum that seems to have just explained the -O- syntax (menaing output result to terminal). Plus this Linux wget doc says: if the file is -, the documents will be written to standard output. (i.e. the second dash means "to standard output"... So at this point I can only assume this "closing dash" syntax only applies to the wget -O option only (and not Linux in general?).
    – Atlas7
    Aug 2, 2015 at 15:21

2 Answers 2

14

For this kind of questions, if you have a browser nearby you might find it handy to use explainshell.com (as man pages can be quite long to go through to find the parameters you interested in):

enter image description here

4
  • 1
    It's not hard at all to find information in manpages—I found this information in 3 keystrokes using less's search feature (/-O).
    – Doorknob
    Aug 2, 2015 at 19:33
  • @Doorknob Sure but you have to look for each parameter you don't know. Aug 2, 2015 at 19:34
  • Great share. Any potential "glitch" to watch out for when using the tool?
    – Atlas7
    Aug 3, 2015 at 8:14
  • @Atlas7 Not that I am aware of. Aug 3, 2015 at 18:28
12

Your search-foo is incomplete. Try man wget, which says, in part:

   -O file
   --output-document=file
       The documents will not be written to the appropriate files, but all will be concatenated together and written to file.  If - is used as
       file, documents will be printed to standard output, disabling link conversion.  (Use ./- to print to a file literally named -.)

       Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell
       redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and all
       downloaded content will be written there.

       For this reason, -N (for timestamp-checking) is not supported in combination with -O: since file is always newly created, it will
       always have a very new timestamp. A warning will be issued if this combination is used.

       Similarly, using -r or -p with -O may not work as you expect: Wget won't just download the first file to file and then download the
       rest to their normal names: all downloaded content will be placed in file. This was disabled in version 1.11, but has been reinstated
       (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use.

       Note that a combination with -k is only permitted when downloading a single document, as in that case it will just convert all relative
       URIs to external ones; -k makes no sense for multiple URIs when they're all being downloaded to a single file; -k can be used only when
       the output is a regular file.

and

   -q
   --quiet
       Turn off Wget's output.
1
  • 1
    Thank you! Looking up man wget now clears things up much more! (I completely forgotten about the man utility - I have been relying on Google too much. This is a wake-up call for me.). I also confirm that the command is the same as wget -q -O- 127.0.0.1 or wget -q -O - 127.0.0.1 - looking at the command in this syntax now appear to "make more sense" to me now. Thanks again.
    – Atlas7
    Aug 2, 2015 at 15:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .