Page 1 of 1

sed for newline character replacement

Posted: Thu Jul 31, 2008 6:08 pm
by yxie
Hi,
I have to change newline characters to space since one record has multiple lines from input file
like
-----------------------
1 2 3
4 5 6
3 5
-----------------------
2 4 6
6 7 8
7 7
-------------------------

In Sequential file stage I used sed 's/\n//g' which is not working
without knowing the meaning of N, sed 'N; s/\n//g' working partially.

Or use transformer stage to merge those lines? by the way all lines are delimited by newline character, no other delimiter defined for each record.

Please advice,

Thanks,

yxie

Posted: Fri Aug 01, 2008 3:03 am
by OddJob
Use awk as a filter in the sequential file stage, something like...

awk '{sOut=$0;getline;sOut=sOut $0;getline;sOut=sOut $0;print sOut}'

You could change to use a loop if it's more than 3 lines per record.

Posted: Fri Aug 01, 2008 3:25 am
by ray.wurlod
Is it always three source lines per output line? If so, all you need is a Transformer stage.

Posted: Tue Aug 19, 2008 11:14 am
by yxie
Thanks Ray & OddJob