我嘗試這種模式在正則表達式101我怎樣才能執行此grep命令
<a href="http://google.com">Google.com</a>
<A target="_blank" href='http://example.com/files.html'>An Example</A>
<a id="link23" HREF = "file23.html" target="_TOP">File #23</a>
<a href="images/mypic.png">See my picture!</a>
<a href="mailto:[email protected]">Email Joel</a>
匹配,並且我做了這個regex- < [AA]。 \ S(HREF | HREF)\ S = \ s?( '|「)。(' |」)> * </[AA]>
現在,當我試圖使用grep命令通過我的命令行,它會拋出一個錯誤。
./mdlinks.sh: line 3: unexpected EOF while looking for matching `"'
./mdlinks.sh: line 4: syntax error: unexpected end of file
這裏是源文件
#! /usr/bin/env bash
CONTENT=$(curl $1)
echo "$CONTENT" | grep -E -o '<[aA].*\s(HREF|href)\s?=\s?('|").*('|")>.*<\/[aA]>' >> mdlinks.txt
http://stackoverflow.com/questions/1881237/easiest-way-to-extract-the -urls-from-an-html-page-using-sed-or-awk-only – MattSizzle
將xmllint與xpath查詢結合使用:http://xmlsoft.org/xmllint.html –