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!

joining lines conditionally 2

Status
Not open for further replies.

clemhoff

Technical User
Jul 10, 2007
19
FR
Hi All,

I'm quite new to awk...
I did search on this forum but did not find a solution to my problem..

The problem i am having is how to write this in awk (or sed ):

- If a line does not end with a parenthese '(', join every following line till one begining with a ')'-

---------- Input
...
<td width="111">
En cours d'acheminement.</td>
<td width="100">
Bordeaux
&nbsp;(
33
100
)
</td>
</tr>
<tr class="tabtxt">
<td width="50">
...etc

---------- Desired output
...
<td width="111">
En cours d'acheminement.</td>
<td width="100">
Bordeaux
&nbsp;(33100)</td>
</tr>
<tr class="tabtxt">
<td width="50">
...etc


Any help would be greatful.
Regards
 
nawk -f chem.awk myFile

chem.awk:
Code:
/\($/ {f=1; printf $0; next}
/^\)/ && f {f=0; print; next}
f { printf $0; next }
1

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Could anyone explain how this code works please?
 
Excuse me for this late answer, I exceptionally granted myself long holidays :)

So, many thanks to Vlad and Feherke for their answers.
(Works perfectly under OS X)


Clement

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top