Page 1 of 1

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

Posted: Fri Sep 01, 2006 6:54 am
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

Posted: Fri Sep 01, 2006 6:57 am
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.

Posted: Fri Sep 01, 2006 7:45 am
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.

Posted: Fri Sep 01, 2006 8:09 am
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

Posted: Fri Sep 01, 2006 8:23 am
by ArndW
Narasa, did my previous suggestion not work?

Posted: Fri Sep 01, 2006 11:12 am
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