combine

Dear all

i am having text file like

xxx|yyy|1|2|
zzz|rrr|3|4|
www|xxx|><
5|6|><
jjj|kkk|><
8|9><

i want to join two lines which are having ' >< ' by taking only two lines at a stretch ...using awk command
the result output should be
xxx|yyy|1|2|
zzz|rrr|3|4|
www|xxx|5|6|
jjj|kkk|8|9|

pls help

pls help

Some thing like this :

 
 
awk 'c==1 { a=a $0 ;print a ;a="";c=0;next } /></ {c=1;a=$0;next} 1' input_file | sed 's/><//g'

another try without the using the pipe :-

nawk -F"|" '($NF in a){print a[$NF] FS $1 FS $2 ;delete a[$NF];next}($NF=="><"){a[$NF]=$1 FS $2 ;next}1' OFS="|" infile.txt

;);):wink: