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
fast search and replace in all files dbsurf Shell Programming and Scripting 21 02-01-2008 12:42 AM
Multiple search in multiple files maxvirrozeito Shell Programming and Scripting 2 12-13-2007 10:32 AM
multiple input search and replace script tungaw2004 UNIX for Dummies Questions & Answers 3 04-29-2007 04:59 AM
Multiple search and replace tungaw2004 UNIX for Dummies Questions & Answers 1 03-21-2007 09:03 PM
cp without maintaining the soucre directory tree hierarchy 435 Gavea UNIX for Dummies Questions & Answers 2 03-03-2006 09:47 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-23-2007
Registered User
 

Join Date: Aug 2005
Posts: 229
Need to search and replace in multiple files in directory hierarchy

Hello all
I need to search and replace in multiple files that are in directory hierarchy
Im using the :
f
PHP Code:
ind . -name "*.dsp" -print | xargs grep --o Test.lib" , I like to be able to 
replace every instance of Test.lib
with empty space .
how can I write one liner that does this ?
Reply With Quote
Forum Sponsor
  #2  
Old 12-23-2007
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 570
Quote:
Originally Posted by umen View Post
Hello all
I need to search and replace in multiple files that are in directory hierarchy
Im using the :
f
PHP Code:
ind . -name "*.dsp" -print | xargs grep --o Test.lib" , I like to be able to 
replace every instance of Test.lib
with empty space .
how can I write one liner that does this ?
Code:
find . -name "*.dsp" | xargs -i sed 's/Test.lib//g' {}
Reply With Quote
  #3  
Old 12-23-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 556
Hi, shamrock.
Quote:
Originally Posted by shamrock View Post
Code:
find . -name "*.dsp" | xargs -i sed 's/Test.lib//g' {}
Did you mean:
Code:
find . -name "*.dsp" | xargs sed -i 's/Test.lib//g'
that is, to supply "-i" to sed as opposed to xargs?

Otherwise, the sed operation will not be written "in place" and the sed output for all files will go to STDOUT ... cheers, drl

Last edited by drl; 12-24-2007 at 04:17 AM.
Reply With Quote
  #4  
Old 12-24-2007
Registered User
 

Join Date: Aug 2005
Posts: 229
If I may ask another question in this thread, what is I like to search string inside close archive like tar or jar
How should my find command look like ?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:17 AM.


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

Content Relevant URLs by vBSEO 3.2.0