The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SED to convert ~ in a file to newline ntekupal Shell Programming and Scripting 5 03-29-2009 11:10 PM
read a line from a csv file and convert a column to all caps orahi001 UNIX for Dummies Questions & Answers 3 12-31-2007 06:05 PM
split line when found newline HAA Shell Programming and Scripting 2 11-19-2007 11:34 AM
Convert a paragraph to single line rimss Shell Programming and Scripting 6 06-07-2006 03:17 PM
append newline to files with incomplete last line ziyi UNIX for Dummies Questions & Answers 1 04-14-2004 09:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-07-2007
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
How to convert ^M appearing at end of line to unix newline?

How to convert ^M appearing at end of line to unix newline?

As I have tried with ^M in 'tr' it replaced ^ to a newline.

Thanks in advance.
  #2 (permalink)  
Old 08-07-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Code:
sed 's/^M/\
/g' filename
^M - ctrl v + ctrl M
  #3 (permalink)  
Old 08-07-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Code:
tr -d '^M' < input_file
As always, '^M' is entered as ctl-V+ctl-M.
  #4 (permalink)  
Old 08-07-2007
joerg's Avatar
joerg joerg is offline
Registered User
  
 

Join Date: Jan 2002
Location: Germany
Posts: 167
Hi,
in solaris you can use the command dos2unix or unix2dos.
I am not sure if this can help you?
Best regards joerg
  #5 (permalink)  
Old 08-07-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Quote:
Originally Posted by Shell_Life View Post
Code:
tr -d '^M' < input_file
As always, '^M' is entered as ctl-V+ctl-M.
But this would delete the ^M characters

But the OP had asked for translating ^M character to a new line
  #6 (permalink)  
Old 08-08-2007
nervous nervous is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 55
What is meant by this:
Code:
^M - ctrl v + ctrl M
  #7 (permalink)  
Old 08-08-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Quote:
Originally Posted by nervous View Post
What is meant by this:
Code:
^M - ctrl v + ctrl M
that's a single character

and to display that on the terminal you need to type ctrl v followed by ctrl M
Closed Thread

Bookmarks

Tags
crlf, dos2unix, linux, linux commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0