簡體   English   中英

bash中的regexp(下載regexp輸出格式)

[英]regexp in bash (downloading output form regexp)

我有一個看起來像的文件:

<a href="some-adress">some-txt</a>
<a href="some-adress">some-txt</a>
<a href="some-adress">some-txt</a>
...

我需要下載所有格式為“ some-address”的文件,我該如何僅使用bash做到這一點?

為什么不使用wget? 它已經具有該功能:

wget -i --force-html yourfile.html

這是結合使用sedxargswget的一種方法:

sed -n 's/.*<a href="\([^"]*\)">.*/\1/p' input-file | xargs wget
cut -f 2 -d '"' file-with-addresses.txt

cut包含在所有posix外殼中。 此命令將使用"作為分隔符來分隔行並返回第二個”字段”。使用wget下載亞當·羅森菲爾德的方法很好。

cut -f 2 -d '"' file-with-addresses.txt | xargs wget

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM