Re: sed, using line number to replace text
- From: Michael Tosch <eedmit@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Nov 2006 23:11:19 +0100
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
.
- Follow-Ups:
- Re: sed, using line number to replace text
- From: Chris F.A. Johnson
- Re: sed, using line number to replace text
- References:
- sed, using line number to replace text
- From: peter_sands@xxxxxxxxxxxxx
- Re: sed, using line number to replace text
- From: Chris F.A. Johnson
- sed, using line number to replace text
- Prev by Date: Re: What is wrong with this script?
- Next by Date: Re: sed, using line number to replace text
- Previous by thread: Re: sed, using line number to replace text
- Next by thread: Re: sed, using line number to replace text
- Index(es):
Relevant Pages
|