Quantcast
Channel: Extracting a specific string after a given string from HTML file using a bash script - Ask Ubuntu
Viewing all articles
Browse latest Browse all 4

Answer by Zanna for Extracting a specific string after a given string from HTML file using a bash script

$
0
0

I can't sensibly advise doing this, because parsing html with regex is not likely to end well but you might be able to get the string MANIKA with

sed -nr '/MOM:/ s/.*MOM:([^"]+).*/\1/p' file

It works OK on your sample anyway...

Notes

  • -n don't print anything until we ask for it
  • -r use ERE
  • /string/ find lines with string
  • s/old/new/ replace old with new
  • .* any number of any characters
  • ([^"]+) save some characters that are not "
  • \1 backreference to saved characters
  • p print just the lines we changed

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>