How to remove carriage retrun from the last line of a file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

How to remove carriage retrun from the last line of a file

Post by reddy »

Sir,

I am concatenating 3 files using exec command stage like this

copy D:\Sequential_Files\CREATEHEADER + D:\Sequential_Files\CREATEDETAIL + D:\Sequential_Files\CREATETRAILER D:\Sequential_Files\BAH_HR_yyyymmdd.txt

but at the end of D:\Sequential_Files\BAH_HR_yyyymmdd.txt file i am

getting carriage return/line feed terminator.

Can you please help me out on how to remove line terminator.

Thanks
Reddy
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Does you windows installation have MKS Toolkit or other unix command emulation installed? If so, you can use the commands "wc -l" and "head" to remove the last line from a file. If not, you can always write a DS job to perform the same functionality.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why bother? If you are going to process all of this, simply add a constraint early in the job that skips that final empty line. Set your "missing field" properties appropriately.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

Post by reddy »

Thanks for quick respond.

Once i combined all 3 files i am sending this file to user but they are telling they are getting problems with line feed terminator.
because of small file i am deleting manually last line.

can you help me on how to remove last line in windows.

Thanks
Narasa
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Narasa, did my previous suggestion not work?
katz
Charter Member
Charter Member
Posts: 52
Joined: Thu Jan 20, 2005 8:13 am

Post by katz »

Hi reddy,

I am not able to recreate your output exactly, but with the COPY command I do get a non-printable character of hex(1A) as the last character of the file.

I don't get this character if I use the /B option (binary file copy) with the COPY command. For example,

Code: Select all

COPY /B file1.txt + file2.txt + file3.txt    fileout.txt
produces an output file with no extra characters at the end. Perhaps you can test the /B option.

katz
Post Reply