使用sed和wget仅检索链接

lee*_*n24 0 linux bash sed

我需要做的是通过命令检索链接,例如:

wget --quiet -O - linkname

然后将其传输到sed,只显示页面上的链接而不是格式化.

到目前为止我只显示了所有html代码旁边的行.

kev*_*kev 6

可以通过管道将结果grep-o(比赛只)选项:

$ wget --quiet -O - http://stackoverflow.com | grep -o 'http://[^"]*'
Run Code Online (Sandbox Code Playgroud)

获取所有网址href="...":

grep -oP '(?<=href=")[^"]*(?=")'
Run Code Online (Sandbox Code Playgroud)