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 > 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 and shell scripting languages 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 03:42 AM
Multiple search in multiple files maxvirrozeito Shell Programming and Scripting 2 12-13-2007 01:32 PM
multiple input search and replace script tungaw2004 UNIX for Dummies Questions & Answers 3 04-29-2007 07:59 AM
Multiple search and replace tungaw2004 UNIX for Dummies Questions & Answers 1 03-22-2007 12:03 AM
cp without maintaining the soucre directory tree hierarchy 435 Gavea UNIX for Dummies Questions & Answers 2 03-03-2006 12: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 12-23-2007
umen umen is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 239
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 ?
  #2 (permalink)  
Old 12-23-2007
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
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' {}
  #3 (permalink)  
Old 12-23-2007
drl's Avatar
drl drl is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 704
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 07:17 AM..
  #4 (permalink)  
Old 12-24-2007
umen umen is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 239
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 ?
Sponsored Links
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 08:23 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