html2 is rather picky about HTML syntax. Try it this way
Code:
content=$(wget -q -O - http://developer.android.com/sdk | sed '/ id="Other"/,$!d')
echo "$content" |
html2 2>/dev/null |
sed -n '\%.*/table/@class=download$%,$!d;/\/td=Linux$/,$!d;\%.*/td/.*/@href=%{s///p;q}'
Or, if you don't have to keep $content around for later use
Code:
wget -q -O - http://developer.android.com/sdk |
sed '/ id="Other"/,$!d' |
html2 2>/dev/null |
sed -n '\%.*/table/@class=download$%,$!d;/\/td=Linux$/,$!d;\%.*/td/.*/@href=%{s///p;q}'
And I guess in this particular case you could also get away with something as simple as
Code:
wget -qO- http://developer.android.com/sdk |
egrep -om1 'http[^"]+sdk[^"]+linux[^"]+'
The last one can actually be rewritten in pure bash as you requested:
Code:
pattern='http[^"]+sdk[^"]+linux[^"]+'
wget -qO- http://developer.android.com/sdk |
while read -r line
do
[[ $line =~ $pattern ]] && printf %s\\n "$BASH_REMATCH" && break
done
Bookmarks