Page 1 of 1

Replace space character with new line character in UNIX file

Posted: Wed Feb 03, 2010 4:29 am
by deepa_shenoy
Hi,

How can we replace space character with new line character in UNIX based file?

For example, if "Dsxchange is helpful" is coming in a single column, I want the ouput in a Sequential File to be in the below format:
Dsxchange
is
helpful

Thanks in advance.
Deepa

Posted: Wed Feb 03, 2010 4:39 am
by DS_SUPPORT
Just replace the space with Char(10), you will get your required output.

Code: Select all

Ereplace(MyString, " ", Char(10)) 
Or
Convert(' ',char(10),MyString) 
I didnt test this code, please do the required changes.

Posted: Wed Feb 03, 2010 3:07 pm
by ray.wurlod
Execute in sequential mode, or make sure that your collector re-assembles the lines in their correct order.

Posted: Thu Feb 04, 2010 9:41 am
by Sainath.Srinivasan
Even though Convert and EReplace may work, it will result in damaging the record as the target is a sequential file.

If you see the full picture, it will be something like
column1, column2, column3,...,Dsxchange is helpful,....,columnN
into
column1, column2, column3,...,Dsxchange
is
helpful,....,columnN
which may not make any sense