sed for newline character replacement

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
yxie
Premium Member
Premium Member
Posts: 10
Joined: Tue Apr 03, 2007 3:46 pm

sed for newline character replacement

Post 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
OddJob
Participant
Posts: 163
Joined: Tue Feb 28, 2006 5:00 am
Location: Sheffield, UK

Post 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.
Last edited by OddJob on Fri Aug 01, 2008 4:04 am, edited 1 time in total.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is it always three source lines per output line? If so, all you need is a Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
yxie
Premium Member
Premium Member
Posts: 10
Joined: Tue Apr 03, 2007 3:46 pm

Post by yxie »

Thanks Ray & OddJob
Post Reply