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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do I replace a word in a file using DOS commands?? sabithareddym Windows & DOS: Issues & Discussions 1 05-22-2008 12:17 AM
replace word in a file ust Shell Programming and Scripting 5 11-30-2007 08:03 PM
Replace word. abu_hassan SUN Solaris 2 03-04-2007 05:14 PM
how to replace a word with another rkrgarlapati Shell Programming and Scripting 1 07-24-2006 07:42 AM
How to replace a word with a series of words in a file brap45 Shell Programming and Scripting 2 02-21-2006 02:33 AM

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-05-2007
sasiharitha sasiharitha is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 3
Replace word in a file

Guys,
I need to replace a portion of the lines in the file depending on the word

in my file i have this content
use DBNAME
go
print "use DBNAME"

i want to replace the variable DBNAME with something else. But the catch is this line is not always "use DBNAME". Sometimes it can be like "use NAME"
Hence i need to find the word use and then replace the word after that.

I am absolutely clueless about this and I would appreciate your help in this

Thanks
Sasi
  #2 (permalink)  
Old 12-05-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Code:
sed '/use/s/DBNAME/perfect/g' a
search for 'use'

and then replace DBANME with perfect
  #3 (permalink)  
Old 12-05-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Is the current thread duplicate of

Need Help with Sed

?
  #4 (permalink)  
Old 12-05-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by matrixmadhan View Post
Is the current thread duplicate of

Need Help with Sed

?
Yes. Closed.
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 11:20 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