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 > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script to find and replace string in multiple files pharos467 Shell Programming and Scripting 11 01-15-2009 11:40 AM
find and replace string in a directory files koti_rama Shell Programming and Scripting 2 05-30-2008 03:48 AM
Find and replace character in a string callimaco0082 UNIX for Dummies Questions & Answers 7 04-10-2008 10:47 AM
How to replace all string instances found by find+grep umen Shell Programming and Scripting 0 12-06-2007 03:52 AM
Find and replace a string in multiple files pharos467 UNIX for Dummies Questions & Answers 2 11-05-2007 11:47 PM

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-16-2006
mridula mridula is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 20
how to find and replace string

hi
I wanted to find this char " ^M " in my file and replace it with blank space.
I am using Unix system.
If i give command " :%s/^M//gc " it wont work
so can anyone tell what is command to find and replace


thankx
  #2 (permalink)  
Old 08-16-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by mridula
hi
I wanted to find this char " ^M " in my file and replace it with blank space.
I am using Unix system.
If i give command " :%s/^M//gc " it wont work
so can anyone tell what is command to find and replace


thankx
You have posted in the "C Programming..." forum. But seeing your command it is actually a non C programming question.

Run dos2unix on the file before you view it i.e. dos2unix input.txt
  #3 (permalink)  
Old 08-17-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Originally Posted by mridula
hi
I wanted to find this char " ^M " in my file and replace it with blank space.
I am using Unix system.
If i give command " :%s/^M//gc " it wont work
so can anyone tell what is command to find and replace


thankx
i suppose the ^M character issued in replace mode is done by typing ctrl-v + ctrl-m -- then it would work definitely.
  #4 (permalink)  
Old 08-17-2006
grumpf grumpf is offline
Registered User
  
 

Join Date: May 2006
Posts: 101
cat file | tr "\r" " " >outfile

in C <pseudocode>:
fd=open()
loop:
read(fd,buf,1)
if (buf== ^M) buf =' '
write(fileno_stdout,buf,1);
clsoe(fd);
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 11:25 PM.


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