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 > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk - replace number of string length from search and replace for a serialized array otrotipo Shell Programming and Scripting 1 07-10-2009 12:04 PM
Problem with sed (search/replace) tipi Shell Programming and Scripting 9 08-26-2008 05:22 PM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 10:24 AM
vi search & replace ... having '/' in string - problem. videsh77 UNIX for Dummies Questions & Answers 6 06-20-2007 01:49 PM
Search and replace sed or tr bridgeje Shell Programming and Scripting 6 10-28-2003 07:54 AM

Reply
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 07-27-2009
Fishn Fishn is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 4
Cool GNU sed - Search and Replace problem

Hi,

The following code loops through every file with an error extension and then loops through all XML files in that directory and replaces the target character @ with / . The problem I have is that if there is more than one occurance of @ in each individual file it doesn't replace it. Any ideas???

P:
for %%f in (*.error) do (
for %%g in (%%~nf\*.xml) do (

IF findstr /L /M /C:@ %%g > nul && "C:\Program Files\GnuWin32\bin\"sed -i -B s/@/\// %%g && rename %%f %%~nf.finished && echo Changes made to %%g >> C:\AnnuityErrors.log
)
)
C:
  #2 (permalink)  
Old 07-28-2009
funksen funksen is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 430
you have to use the global flag "g" at the end
Code:
sed -i -B s/@/\//g
  #3 (permalink)  
Old 07-28-2009
Fishn Fishn is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 4
Many Thanks!!

Thanks very much, it works like a dream.
Reply

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 04:13 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