Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global change in html source file 1

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL

hello,
I have a html file with many lines like:
<p><font size="1">a1</font></p>
<p><font size="1">val1</font></p>
</td>
<td>
<p><font size="1">a4</font></p>
<p><font size="1">val2</font></p>
</td>
<td>
<p><font size="1">a...</font></p>
<p><font size="1">val...</font></p>

and I'd like to change each pair like:
<p><font size="1">a1</font></p>
<p><font size="1">val1</font></p>
to:
<p><font size="1">a1 val1</font></p>

(all the rest in the html file should be as it is)

so finally get something like:

<p><font size="1">a1 val1</font></p>
</td>
<td>
<p><font size="1">a4 val2</font></p>
</td>
<td>
<p><font size="1">a... val...</font></p>



 
Hi

This is one ugly and rigid piece of code which works for the exact input you posted :
Code:
awk '[fuchsia]/font/[/fuchsia][teal]{[/teal][b]sub[/b][teal]([/teal][fuchsia]/<\/.+/[/fuchsia][teal],[/teal][i][green]""[/green][/i][teal]);[/teal][b]sub[/b][teal]([/teal][fuchsia]/.+>/[/fuchsia][teal],[/teal][i][green]""[/green][/i][teal]);[/teal][navy]v[/navy][teal]=[/teal][navy]v[/navy] [teal]([/teal]v[teal]?[/teal]OFS[teal]:[/teal][i][green]""[/green][/i][teal])[/teal][navy]$0[/navy][teal];[/teal][b]next[/b][teal]}[/teal][fuchsia]/<\/td>/[/fuchsia][teal]{[/teal][b]print[/b][i][green]"<p><font size=[/green][/i][lime]\"[/lime][i][green]1[/green][/i][lime]\"[/lime][i][green]>"[/green][/i]v[i][green]"</font></p>"[/green][/i][teal];[/teal][navy]v[/navy][teal]=[/teal][i][green]""[/green][/i][teal]}[/teal][purple]1[/purple]' /input/file
Tested with [tt]gawk[/tt] and [tt]mawk[/tt].


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top