fork(1) download
  1. #!/bin/bash
  2.  
  3. html='<html>
  4. <body>
  5. <div id="foo" class="foo">
  6. Some Text.
  7. <p id="author" class="author">
  8. <br>
  9. <a href="example.com">bar</a>
  10. </p>
  11. </div>
  12. </body>
  13. </html>'
  14.  
  15. text="$(sed 's:^ *::g' <<<"$html" | tr -d \\n)"
  16. author=$(sed 's:.*<p id="author" class="author"><br><a href="[^"]*">\([^<]*\)<.*:\1:' <<<"$text")
  17. quote=$(sed 's:.*<div id="foo" class="foo">\([^<]*\)<.*:\1:' <<<"$text")
  18. echo "'$author' '$quote'"
Success #stdin #stdout 0s 19640KB
stdin
Standard input is empty
stdout
'bar' 'Some Text.'