Append line that does not contain pipe to it previous line

Hi All,

I have a file which contains data as below
When we see no pipe character in the line. append those lines to the previous line with pipe character till we get the next line with pipe character with ~(concat with ~)
Input file looks like:
1080530944|001|john.l.bonner|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:49:735|2007/06/28-16:25:48:662|
1080530944|001|larry.d.groves|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:49:931|2007/06/21-20:13:41:581|
1080530944|001|michael.g.krumheuer|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:099|2007/06/25-14:08:22:330|
1080530944|001|paul.j.frederick|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:234|2007/06/22-13:14:19:439|
1080530944|001|rich.jester|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:355|2007/06/21-14:25:43:604|
1080530944|001|robert.g.campbell|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:470|2007/08/30-15:31:49:127|
1080530944|001|douglas.h.markwood|Reassigned|Monitor & Control Change Notice in the Holding Area|2007/06/20-18:42:01:259|2007/06/20-18:45:42:324|s b295 Please monitor this change and update the ITA with any/all completion dates.
When you have completed the changes and it has been implemented,
Complete this task on your show list and "reassign" the next task back to me.
E-mail me with the Actual Effectively and Completion dates. Thanks Doug M.
1080530944|001|robert.g.campbell|Complete (See Comments)|Monitor & Control Change Notice in the Holding Area|2007/06/20-18:45:42:536|2007/08/30-15:38:28:067|ok

Output File should be:

1080530944|001|john.l.bonner|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:49:735|2007/06/28-16:25:48:662|
1080530944|001|larry.d.groves|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:49:931|2007/06/21-20:13:41:581|
1080530944|001|michael.g.krumheuer|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:099|2007/06/25-14:08:22:330|
1080530944|001|paul.j.frederick|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:234|2007/06/22-13:14:19:439|
1080530944|001|rich.jester|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:355|2007/06/21-14:25:43:604|
1080530944|001|robert.g.campbell|Acknowledge|CN Approved-Implement Change to Meet Target Effectivity Date|2007/06/20-18:41:50:470|2007/08/30-15:31:49:127|
1080530944|001|douglas.h.markwood|Reassigned|Monitor & Control Change Notice in the Holding Area|2007/06/20-18:42:01:259|2007/06/20-18:45:42:324|s b295 Please monitor this change and update the ITA with any/all completion dates.~When you have completed the changes and it has been implemented,~Complete this task on your show list and "reassign" the next task back to me.~E-mail me with the Actual Effectively and Completion dates. Thanks Doug M.
1080530944|001|robert.g.campbell|Complete (See Comments)|Monitor & Control Change Notice in the Holding Area|2007/06/20-18:45:42:536|2007/08/30-15:38:28:067|ok

Use nawk or /usr/xpg4/bin/awk on Solaris:

awk 'END { print l }
{ l = l ? l (/\|/ ? RS : "~" ) $0 : $0 }
/\|/ && f { print l; l = f = 0 }
!/\|/ { f = 1 }' infile

Great! Excellent. It worked.
However it missed out very few data. i did that manually.

thanks a lot for your help.

Hm,
even after adding the END block (I've modified the initial code)?

perl:

open FH,"<file";
while(<FH>){
	$t++;
	if(m/\|/){
		$arr[$t]=$_;
	}
	else{
		$t--;
		$arr[$t]=~s/\n//g;
		$arr[$t]=sprintf("%s~%s",$arr[$t],$_);
	}
	
}
close FH;
foreach(@arr){
	print;
}

Hi Radouluv,Summer_cherry.

Thanks both of you it worked.

I am struggling to format the output with awk. i need a report file.

your help on this will be appreciated.

Fallowing is the input file that is pipe seperated.
is it possible to generated the report that is alligned left justifed as that of sample output.
I apprecitae your help on this.
InputFile:

108005555|001|christina.lipski||Submitter Signature|2005/05/09-19:16:19:021|2005/05/10-15:52:36:112| eSCR 10744 attachment in REF file
108005555|001|james.m.thompson|Unable to Complete (See Comments)|Initial Change Request Assessment|2005/05/09-19:16:21:794|2005/05/10-15:00:48:486|1 Christina Lipski
~In the body of the change request I cut and pasted Jim Lopez's comments. According to him, the inductance limit is already complete and the eSCR should have been describing a different request to change the process. Read the comment. The eSCR should probably be rejected and re-issued with the proper description. 
108005555|001|james.m.thompson||Submitter Signature|2005/05/10-15:00:25:440|2005/05/10-15:00:54:659|0 Mike,
~Do you agree that this eSCR should be reissued by the supplier AND that you should be the change owner?
108005555|001|super user|OK - See Comments|Read the comments and correct me if I'm wrong.|2005/05/10-15:00:27:109|2005/05/10-15:00:53:687| Auto-signoff for Advisor Participant "james.l.lopez" to remove from inbox.
108005555|001|super user|OK - See Comments|Read the comments and correct me if I'm wrong.|2005/05/10-15:00:27:187|2005/05/10-15:00:53:964| Auto-signoff for Advisor Participant "michael.s.thompson" to remove from inbox.
108005555|001|christina.lipski|Complete (See Comments)|Perform additional work on CR|2005/05/10-15:01:00:066|2005/05/10-15:20:26:144| CR cannot be completed. Please reject. 
108005555|001|james.m.thompson|Unable to Complete (See Comments)|Initial Change Request Assessment|2005/05/10-15:20:28:870|2005/05/10-15:52:11:597| eSCR that initiated this change request had wrong information. eSCR is rejected.

Output File Should look like

==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
USER                     ACTION TAKEN    ASSIGNMENT     TIMESTAMP IN    SIGNOFF DATE             COMMENTS  
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
christina.lipski      Submitter Signature    2005/05/09-19:16:19:021   2005/05/10-15:52:36:112    eSCR 10744 attachment in REF file
james.m.thompson          Unable to Complete (See Comments) Initial Change Request Assessment  2005/05/09-19:16:21:794   2005/05/10-15:00:48:486   1 Christina Lipski~In the body of the change request I cut and pasted Jim Lopez's comments. According to him, the inductance limit is already complete and the eSCR should have been describing a different request to change the process. Read the comment. The eSCR should probably be rejected and re-issued with the proper description. 
james.m.thompson      Submitter Signature    2005/05/10-15:00:25:440   2005/05/10-15:00:54:659   0 Mike,~Do you agree that this eSCR should be reissued by the supplier AND that you should be the change owner?
super user                OK - See Comments   Read the comments and correct me if I'm wrong. 2005/05/10-15:00:27:109   2005/05/10-15:00:53:687    Auto-signoff for Advisor Participant "james.l.lopez" to remove from inbox.
super user                OK - See Comments   Read the comments and correct me if I'm wrong. 2005/05/10-15:00:27:187   2005/05/10-15:00:53:964    Auto-signoff for Advisor Participant "michael.s.thompson" to remove from inbox.
christina.lipski          Complete (See Comments)  Perform additional work on CR   2005/05/10-15:01:00:066   2005/05/10-15:20:26:144    CR cannot be completed. Please reject. 
james.m.thompson          Unable to Complete (See Comments) Initial Change Request Assessment  2005/05/10-15:20:28:870   2005/05/10-15:52:11:597    eSCR that initiated this change request had wrong information. eSCR is rejected.

I have tried the fallowing AWK script. did not help me with the correct format.

Did you try a tab separated fields?

 awk -F\| '$1=$1' OFS='\t' infile

I have tried the fallowing AWK script. did not help me with the correct format.
awk -F"|" '
BEGIN {
print "==========================================================================================================================================================="
printf "%-25s%-25s%-10s%-25s%-25s%-10s\n","USER","ACTION TAKEN","ASSIGNMENT","TIMESTAMP IN","SIGNOFF DATE","COMMENTS"
print "===========================================================================================================================================================\n"
}
{
printf "%-25s %-25s %-10s %-25s %-25s %-10s\n",$3,$4,$5,$6,$7,$8
}
END {
print ""
}
'temp.txt

And what's wrong with the output from that command?

I have tried the fallowing AWK script. did not help me with the correct format.

awk -F"|" '
BEGIN {
print "==========================================================================================================================================================="
printf "%-25s%-25s%-10s%-25s%-25s%-10s\n","USER","ACTION TAKEN","ASSIGNMENT","TIMESTAMP IN","SIGNOFF DATE","COMMENTS"
print "===========================================================================================================================================================\n"
}
{
printf "%-25s %-25s %-10s %-25s %-25s %-10s\n",$3,$4,$5,$6,$7,$8
}
END {
print ""
}
'temp.txt

I have attached input file temp.txt.

i am trying to run that against my command.
awk -F"|" '
BEGIN {
print "==========================================================================================================================================================="
printf "%-25s%-25s%-10s%-25s%-25s%-10s\n","USER","ACTION TAKEN","ASSIGNMENT","TIMESTAMP IN","SIGNOFF DATE","COMMENTS"
print "===========================================================================================================================================================\n"
}
{
printf "%-25s %-25s %-10s %-25s %-25s %-10s\n",$3,$4,$5,$6,$7,$8
}
END {
print ""
}
'temp.txt > Report.TXT

This does not generate the output in correct format as i wished.

Please see Report.TXT attachment.

You need to adjust the column width,
try changing the numbers. Something like this (try with other values too):

awk -F\| 'BEGIN {
  mask = "%-36s%-36s%-20s%-36s%-36s%-20s\n"
  print "===========================================================================================================================================================\n"
  printf mask, "USER", "ACTION TAKEN", "ASSIGNMENT", "TIMESTAMP IN", "SIGNOFF DATE", "COMMENTS"
  print "===========================================================================================================================================================\n"
  }
{
  printf mask, $3, $4, $5, $6, $7, $8
} END {
  print RS
  }' temp.txt