shell - Delete strings from an html file containing a pattern using unix commands -


i have messy html looks this:

<div id=":0.page.0" class="page-element" style="width: 1620px;">  <div>   <img src="viewer_files/viewer_004.png" class="page-image" style="width: 800px; height: 1131px; display: none;">   <img src="viewer_files/viewer_005.png" class="page-image" style="width: 1600px;">  </div> </div>// repeats 100+ times different 'src' attributes 

now 1 line actually (i have formatted in multiple lines easy readibility). trying remove <img> tags have display:none; set in inline css. possible use sed/awk or other unix command achieve this? think if indented html document, would've been easy.

sed -e "s/<img[^>]*display: none;[^>]*>//g" filein 

a quick explanation sed :

s stands substitution / delimiters

s means first field pattern search, replaced second one. last 1 options. g means global (replace many times if many matches found).

to replace inplace : sed -i -e "..."


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -