Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to replace end of line characters

Posted on 2004-09-22
6
Medium Priority
?
1,227 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 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
Technology Partners: 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

670 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