The UNIX and Linux Forums  

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
get last characters in ksh meghana Shell Programming and Scripting 5 04-11-2008 05:11 PM
Check for special characters in a script sumesh.abraham Shell Programming and Scripting 7 12-18-2006 09:15 AM
Add few characters er_aparna Shell Programming and Scripting 7 08-17-2006 11:53 AM
characters ô ö à é è Castelior Shell Programming and Scripting 1 04-19-2006 11:52 AM
Script to check for a file, check for 2hrs. then quit mmarsh UNIX for Dummies Questions & Answers 2 09-16-2005 03:46 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-15-2008
ladtony
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Unhappy How to check for contrl-M characters

Hii

When i am using the following command for checking the ctrl-m characters am getting "Substitution pattern match failed" error.
Actually i jus want to check and not to substitute.
Please suggest me as whats wrong in the below command.

1,$s/Ctrl+vCtrl+m//g

Thanks
  #2 (permalink)  
Old 08-15-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Probably the application you are using doesn't support using literal control-M:s in regex substitution. Is this sed or vi or some other beast? Is there a reason you don't just run dos2unix or comparable on the file? There is regrettably no single standard portable command which works everywhere, but search this site for "ctrl-m" or "carriage return" or "DOS" or ...
  #3 (permalink)  
Old 08-15-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,323
As era said or try out


Code:
cat infile| tr -d '\015' > newfile

Btw., you don't have to explicit address from 1 to $ since if you don't specify an address, it will process the whole input file.
  #4 (permalink)  
Old 08-15-2008
ladtony
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
thanks....Zaxxon...
but what is 015 in the command u gave
  #5 (permalink)  
Old 08-15-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,323
That's the octal value for ^M.

Btw., the better way to write it (saving the cat), correcting myself, is:

Code:
tr -d '\015' < infile > outfile

  #6 (permalink)  
Old 08-15-2008
incredible incredible is offline Forum Advisor  
Registered User
  
 

Join Date: May 2008
Location: s'pore
Posts: 2,127
Just curious, why would you want to just check for? Any purpose for it? :/
  #7 (permalink)  
Old 08-15-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,423
i fyou just wanna check for^M char
open the file in vi editor press escape then type /ctrl+vctrl+m
this should work...
Closed Thread

Bookmarks

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:19 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