bash script to apply sed command only to a specific text area
Dear all,
I need to apply an sed argument to specific text area in a html file. first need to find the pattern <font=xxx> </font> then apply sed argument within the font tag only. can any one help me to write this bash script? |
well that's the point of sed...
sed 's/\<font color\=red/\<font color\=blue/g' file.txt should do it as an example. |
Quote:
My need is not just changing the font tag. I don't want to change it. I need to apply a sed argument to the text which coming within the specific font tag. The argument should not be applied to the other text in that html file. |
Quote:
The sed replace (s) command will change the 1st instance or, with the "g" added, ALL instances. I seem to recall that there is a way to select a specific number of instances. My favorite tutorial on sed is here: http://www.grymoire.com/Unix/Sed.html It will help to post an example of text that you want to change. |
that's still just a standard sed command, not sure what the issue is...
sed 's/\<font color\=red\>some\ data\ here/\<font color\=red\>some\ new\ data/g' file.txt |
ok I'll explain it in detail.
here is the html file. Quote:
You can see there are two font varients. 1. <FONT FACE="Bitstream Charter, serif">&&&&&&&&&&&</FONT> 2. <FONT FACE="Bamini">**********</FONT> the script will search entire html, and will find the pattern <FONT FACE="Bamini">**********</FONT> and then it will apply this sed command only to the text which situated by "<FONT FACE="Bamini">**********</FONT>" tags (the *****) Quote:
|
as above. that is what sed is for. this is not special in any way whatsoever...
|
All times are GMT -5. The time now is 04:43 AM. |