2012-11-20 192 views
1

輸入從wget的手冊頁的wget從標準輸入讀取

§ 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. 

我試圖做

wget -i - www.google.com 

它下載的文件index.html,但後來死了。即使在我按了幾次「Enter」後仍然掛起了 。爲什麼?

回答

3

因爲您還沒有關閉您的'文件'wget會繼續等待您輸入更多標準輸入。要終止,按ctrl + d [EOF終止符]

+0

按ctrl + d會給你'沒有在URL中找到的URL。 已完成--2012-11-20 23:15:43-- 下載:1個文件,12K在0.001s(14.9 MB/s)'消息 – Anshul

+0

這對'grep google urlList.txt | wget -i -'(即下載文件中的每個頁面,其中包含「google」)。如果您只想在命令行中傳遞URL,您可以執行'wget url1 url2'。 – Inductiveload