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
How to test for file update CraigMoore UNIX for Advanced & Expert Users 1 10-07-2008 10:39 AM
update a file with values from other file in shell bash teodora Shell Programming and Scripting 1 07-03-2008 11:39 AM
file update piyush_movadiya Shell Programming and Scripting 8 06-27-2007 07:39 AM
update file command help maoro UNIX for Dummies Questions & Answers 0 05-07-2007 06:10 AM
update a file by key ynixon Shell Programming and Scripting 25 03-29-2007 09:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-17-2008
aoussenko aoussenko is offline
Registered User
  
 

Join Date: May 2008
Posts: 119
how to update a file

-Hi, I have several hundred files, which contain the following pattern:
/bb/bin/msga/mm 80&
I need to change the above pattern to be
/bb/bin/mm 80&
I there the command I can use to do that. Thanks a lot
  #2 (permalink)  
Old 11-17-2008
mylostone mylostone is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
for file in `grep -R '/bb/bin/msga/mm' .`; do perl -p -i.bak -e 's:/bb/bin/msga/mm:/bb/bin/mm:' "$file"; done
  #3 (permalink)  
Old 11-17-2008
zouhair zouhair is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 12
Or just :

sed "s/msga\///" <file
  #4 (permalink)  
Old 11-17-2008
Lakris Lakris is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 240
Hi, another view, and a question; are all the files You want to change in the same directory? Then You could try something like

Code:
sed -i.bak -e "s_/bb/bin/msga/mm 80\&_/bb/bin/mm 80\&_g" *
the -i.bak saves the original with a bak-extension just in case.

/Lakris
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 07:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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