Page 1 of 1

Remove Carriage Return from the end of the file

Posted: Tue Apr 26, 2011 11:00 am
by kashif007
Hello All

I am producing a fixed width file with a carriage return in the last column of each record in the file. The business wants carriage return on all other records except the last record. Can anyway suggest me how can I remove the carriage return at the EOF. If possible, I don't want to remove the carriage return but replace the last carriage return with a space. That way I maintain the fixed length of the record intact.

Thanks

Posted: Tue Apr 26, 2011 11:25 am
by zulfi123786
check the record delimiter string option of seq file stage it that helps.

Posted: Tue Apr 26, 2011 11:59 am
by kashif007
I have already tried various Sequential file options but it did not help. I am looking for a UNIX command to fix this issue.

Following is the scenario. I have a file called "file1" which has the following content.

abc
xyz
123
etc
etc
etc
<-------------------- Blank line to remove

How do I get ride of this blank line at the end. I have already tried the following SED command

sed "$d" file1 > file2

but the carriage return does not go away.

Re: Remove Carriage Return from the end of the file

Posted: Tue Apr 26, 2011 1:01 pm
by paultechm
Hi,
Read the file as a single varchar column(without data length) , remove the blank line based on the length.Use column export to split the records into multiple columns

-Paul

Posted: Wed Apr 27, 2011 12:23 am
by zulfi123786
kashif007 wrote:I have already tried various Sequential file options but it did not help. I am looking for a UNIX command to fix this issue.
If it is unix that you want to work with, the below should help you.

sed '$d' xyz.dat>tmp.dat
tail -1 xyz.dat|tr -d \n>>tmp.dat
mv tmp.dat xyz.dat