Re: sed, using line number to replace text



Chris F.A. Johnson wrote:
On 2006-11-20, peter_sands@xxxxxxxxxxxxx wrote:
Hi,
I am converting a .csv file into an HTML file, all looks good apart
from one little problem. I need to make some sed inserts ( well I think
sed will do it ),
For every occurance of the word 'CLAIMS', within that line there is an
amount figure. I need to make that number bold as well, so I need to
insert a <B>, before the number. Using 'grep -n ' I can extract the
line numbers, see below:

183:<TR ALIGN=CENTER><TH>33003</TH><TD><B>CLAIMS
EUC</B></TD><TD></TD><TD>
</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD>21781</TD>

340:<TR ALIGN=CENTER><TH>33003</TH><TD><B>CLAIMS
EUX</B></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD>7892</TD>

But how can I in sed use that line number , to change insert a tag.
What I need to end up with is something like... <B>7892</B>, like so::
<TR ALIGN=CENTER><TH>33003</TH><TD><B>CLAIMS EUX</B></TD><TD></TD><TD
</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD><B>7892</B></TD>

sed -e '183 s/[0-9]*/<b>&</b>/' \
-e '340 s/[0-9]*/<b>&</b>/' \

Or is there a better way of doing it.

sed '/CLAIMS/ s/[0-9]*/<b>&</b>/'


Correction:
sed '/CLAIMS/ s/[0-9]*/<b>&<\/b>/'

--
Michael Tosch @ hp : com
.



Relevant Pages