Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to replace end of line characters

Posted on 2004-09-22
6
Medium Priority
?
1,228 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 200 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
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!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

824 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