开发者

regexp in bash (downloading output form regexp)

I have got a file that look like:

<a href="some-adress">some-txt</a>
<a href="some-adress">some-txt</a>
<a 开发者_高级运维href="some-adress">some-txt</a>
...

I need to download all files that are as "some-adress", how can I do that using only bash?


Why don't you use wget ? It already have that feature :

wget -i --force-html yourfile.html


Here's one way to do that using a combination of sed, xargs, and wget:

sed -n 's/.*<a href="\([^"]*\)">.*/\1/p' input-file | xargs wget


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

cut is included in all posix shells. This command will split the line using the " as the delimiter and return the second "field". To download using wget Adam Rosenfield's method is fine.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜