Solved

How to replace end of line characters

Posted on 2004-09-22
6
1,225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 97
xyBalance chalenge 58 104
Host to IP 7 84
noX challenge 17 144
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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