wget read input from standard input

2019-07-07 05:23发布

问题:

From the wget man page

§ 2.4 Logging and Input File Options

‘-i file’
‘--input-file=file’
     Read urls from a local or external file. If ‘-’ is specified as file, urls
     are read from the standard input. (Use ‘./-’ to read from a file literally
     named ‘-’.)

     If this function is used, no urls need be present on the command line. If
     there are urls both on the command line and in an input file, those on the
     command lines will be the first ones to be retrieved. If ‘--force-html’ is
     not specified, then file should consist of a series of URLs, one per line.

I tried doing

wget -i - www.google.com

It downloaded a file index.html, but then it hangs. Even after I pressed "Enter" several times, it still hangs. Why?

回答1:

Because you have not closed your 'file' wget continues waiting for you to type more into stdin. To terminate, press ctrl + d [EOF terminator]



标签: wget stdin