Solved

How to replace end of line characters

Posted on 2004-09-22
6
1,223 Views
Last Modified: 2013-12-26
Hello,
I learned it but I can't remember it!

When I bring over datafiles from my Windows XP box to upload into the Oracle DB I save the Excel file as a .csv file.  I then FTP it to the UNIX box.

When I open it up in VI on the UNIX box (HPUX 10.2) I have ^M as the end of line character for each line.

How do I do a replace with nothing on the ^M using Replace, SED or whatever??.  Should I be changing a setting somewhere in my FTP so that I don't get the odd character??

Thanks, Jerry (just learning)
0
Comment
Question by:geraldw
6 Comments
 
LVL 11

Accepted Solution

by:
avizit earned 50 total points
ID: 12123405
do check if your unix has a

dos2unix command  i.e do a "which dos2unix "

if it exists you can simply do a

dos2unix filename

0
 
LVL 11

Expert Comment

by:avizit
ID: 12123417
and also

perl -p -e 's/\n/\r\n/' < unixfile.txt > winfile.txt
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12123582

You could use this tr command to filter ^M chars from its std input:

tr -d "\015"

0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12123624
The other option is to use ascii mode (rather than binary mode) in FTP,
which performs the translations for you.  check out the 'ascii' and 'cr'
ftp commands in the man page.
0
 
LVL 18

Expert Comment

by:liddler
ID: 12123948
just for completion
sed 's/^M//g' winfile.csv > unixfile.csv
0
 

Author Comment

by:geraldw
ID: 12124232
Thanks folks,
it looks like all are good answers and I'll give the points to avizit since he was first.  Thanks for the other suggestions.  I know I'll use them at some point.
J
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 51
EvenOdd challenge 10 127
noX challenge 17 129
Remove Password Protection from pdf (with password) using an command line executable 5 63
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question