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

Extracting a specific string after a given string from HTML file using a bash script

$
0
0

I have a HTML file momcpy.html from which I want to extract a specific string after a given string. File content is like:

<tr><br>
<th height="12" bgcolor="#808080"><label for="<br>
 LSCRM:Abhijeet<br>
 <br>
 MCRM:Bhargav<br>
 <br>
 TLGAPI:GAURAVAURAV<br>
 <br>
 MOM:MANIKA"></td><br>

This is present on one of the lines of HTML.

I want to extract Manika and store it in a variable. So Basically I want to extract whatever string is present after MOM:, It could be dynamic.

I have tried:

file='/home/websphe/tomcat/webapps/MOM/web/momcpy.html'
  y=$( awk '$1=="MOM:"{print $2}' $file)
 echo "$y"

But that didn't work.


Viewing all articles
Browse latest Browse all 4

Trending Articles



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