The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Whi I'm getting control-M's padpa UNIX for Dummies Questions & Answers 14 12-13-2007 03:18 AM
Fan control Timmy66 BSD 1 08-02-2007 06:59 AM
Job control bobk544 Shell Programming and Scripting 3 04-05-2007 05:31 AM
New to Control-M oraclenerd UNIX for Advanced & Expert Users 5 05-18-2006 07:21 AM
Identifying and removing control characters in a file. oracle8 High Level Programming 0 04-13-2004 03:08 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-02-2006
Registered User
 

Join Date: Feb 2006
Posts: 27
Stumble this Post!
Removing control-Ms (^M)

Anyone know how to remove ^M's from a text file using sed command?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-02-2006
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Stumble this Post!
You just have to remove the last character since its the last ...
Code:
sed -e 's/.$//g' file > file2
Reply With Quote
  #3 (permalink)  
Old 03-02-2006
Registered User
 

Join Date: Feb 2006
Posts: 27
Stumble this Post!
No, i'm returning a record from the DB, and one of the fields has ^Ms contained within it. This means it won't be the last character unfortunately.
Reply With Quote
  #4 (permalink)  
Old 03-02-2006
bhargav's Avatar
Registered User
 

Join Date: Sep 2004
Location: USA
Posts: 511
Stumble this Post!
Code:
sed 's/^M// file    # Press Ctrl-V then Ctrl-M to get ^M
Reply With Quote
  #5 (permalink)  
Old 03-03-2006
Registered User
 

Join Date: Feb 2006
Posts: 27
Stumble this Post!
for anyone that wants to know i found a different piece of code to use

#*********************************************************
# CHANGE LOG:
# DATE PERSON COMMENT
# ----------- ----------- -----------
# 28 FEB 2006 DARREN KANE CREATED
#*********************************************************

FILE=$1

/bin/tr -d '\015' < $FILE > t.$$
/bin/mv -f t.$$ $FILE
Reply With Quote
  #6 (permalink)  
Old 03-03-2006
Registered User
 

Join Date: Feb 2006
Location: Southern England
Posts: 102
Stumble this Post!
unix2dos
dos2unix
Reply With Quote
  #7 (permalink)  
Old 03-06-2006
Registered User
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 124
Stumble this Post!
or, dependant on your system

ux2dos
dos2ux
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0