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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple row concatenations

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
What is wrong with the code below? Or, how should I write it if it is incorrect altogether?

Here are the rules:
All true rows can be on multiple physical rows
I need to get those true rows onto one physical row.
The end of a true row has a pipe/newline ( /\|$/ )at the end of any given sequential physical row.

BEGIN
$0 ~ /\|$/
{ if (match($0, '/\|$/'))
currow = currow + " " + substr( $0, 1, $0 - 1 )
else
currow = currow + " " + $0 + " "
}
 
Hi Jlipman!

This bit of code will do the job.

#! /bin/sh

nawk 'BEGIN{FS=""}

{
while ($0 ~ /\|$/) {
gsub(/\|$/," ")
printf ("%s", $0)
getline
}

if ($0 !~ /\|$/) {
printf("%s\n", $0)
}

}' $1 > $2

Hope this helps you.


flogrr
flogr@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top