The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Aug 2006
Posts: 17
Interesting question - Search and replace the word after sign "="

Hi Guys,

Req your help in searching and replacing the word that comes after equals(=) symbol

I would like to replace the sting in bold with a string in variable.

d=ABCDF8C44C22
# grep -i NIM_MASTERID ${_NIMINFO}
export NIM_MASTERID=00CDF8C44C00

I'm looking to replace any word that comes after "=" symbol in the above grep statement output.

like to see the output as export NIM_MASTERID=ABCDF8C44C22
after replacing export NIM_MASTERID=00CDF8C44C00


Thanks
  #2 (permalink)  
Old 11-27-2009
dj - the student
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 667
Try:


Code:
echo "export NIM_MASTERID=00CDF8C44C00" | sed 's/\(.*\)=.*/\1=ABCDF8C44C22/'

  #3 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Oct 2009
Location: UK
Posts: 225
slightly stronger: -
Code:
echo "export NIM_MASTERID=00CDF8C44C00" | sed 's/\(NIM_MASTERID=\).*/\1ABCDF8C44C22/'

  #4 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Jun 2006
Posts: 468

Code:
awk -v d="ABCDF8C44C22" 'BEGIN {FS=OFS="="} /NIM_MASTERID/ {$2=d}1' ${_NIMINFO}

  #5 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,258

Code:
d=ABCDF8C44C22
# grep -i NIM_MASTERID ${_NIMINFO}|sed "s/=.*/=$d/"

Sponsored Links
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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed: a "replace unless match" question Bubnoff Shell Programming and Scripting 0 08-17-2009 10:34 PM
Additional question to "awk to replace particular field" VGR Shell Programming and Scripting 1 06-18-2009 11:05 AM
A question/problem about oracle "tns listener" and "enterprise manager" talipk UNIX for Advanced & Expert Users 1 12-03-2008 07:55 AM
A question/problem about oracle "tns listener" and "enterprise manager" talipk UNIX and Linux Applications 0 12-01-2008 03:08 PM
replace word with using "sed" not work... happyv Shell Programming and Scripting 28 03-01-2007 03:10 AM



All times are GMT -4. The time now is 10:55 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