Hi is it possible to edit a .html file using regex contained inside a bash scrip?
Here is what i am trying to do:
replaceText="<a href="some-file-here" id="text">link to the new file</a>"
#open index.html file stream(how?)
#do some if condition that meets the regex below:
IF index.html contains <td abbr="fileOne">(.*)</td>
Index.html replaceText
I'm quite new to bash scripting but I was wondering if the above is possible?
This has to work on both osx unix and linux.
Here is the index.html example:
<html>
<head>
</head>
<body style="width: 50%; height: 50%;">
<div style="top: 10%; left: 10%; position: absolute;">
<img border="0" src=“icon.png” alt="Hello World" width="120" height="120">
<table style="width:300px">
<tr>
<td abbr=“file one”><a href=“someFile” id="text">Install file one here…</a></td>
<td abbr=“fileTwo”><a href=“someFileTwo” id="text">install file Two here…</a></td>
<td></td>
</tr>
</table>
</div>
</body>
</html>
Thanks in advance
edit: i tried using sed command be
sed -i.bak 's/<td abbr="fileOne">(.*?)<\/td>/WHAT_YOU_WANT/' index.html
however i get the above error when i open the .bak file:
syntax error near unexpected token `newline'