我目前正在尝试学习Linux命令和正则表达式,我陷入了一个小问题,我试图使用sed和正则表达式在文件中找到一系列链接,任何人都可以帮助我工作这出了什么地方,我错了。链接是这样的与正则表达式找到链接
<a href="../a-lot-of-different/words-that/should-link.html">Useful links</a>
<a href="..//a-lot-of-different/words-that/should-find-lots-of-links.html">Multiple links</a>
<a href="../another-word-and-links/multiple-words/sjshfi-dfg.html">more links</a>
这就是我所拥有的。
sed -n '/<a*href=”^[../"]*\([a-z]*\)^[.html](["]*\)/p' /file > newfile
如果它是一个HTML文件,我建议使用DOM解析器。请参阅http://unix.stackexchange.com/questions/6389/parse-html-on-linux和http://stackoverflow.com/questions/893585/how-to-parse-xml-in-bash – Phil 2014-10-29 23:31:32