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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 10:24 AM
Search and Replace in Ksh DeepakXavier Shell Programming and Scripting 9 05-28-2007 09:11 AM
sed search and replace d__browne UNIX for Dummies Questions & Answers 7 04-26-2006 10:46 AM
Help, sed search&replace mle Shell Programming and Scripting 2 02-13-2004 01:28 PM
Search and replace sed or tr bridgeje Shell Programming and Scripting 6 10-28-2003 07:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-11-2007
vaibhavs vaibhavs is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 4
tricky search replace: Pls help.

Hi,

I have a a mysql dump text file.

I need to replace the below line
-------------------------------------------------------------------
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;
-------------------------------------------------------------------

with this text

-------------------
) TYPE=MyISAM;
-------------------

using a shell script.

How can I do this.
Please help.

Thank you in advance.

regards,
Vai
  #2 (permalink)  
Old 06-11-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,807
One way:

Code:
sed 's/ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;/TYPE=MyISAM;/' oldfile > newfile

  #3 (permalink)  
Old 06-11-2007
vaibhavs vaibhavs is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 4
Hi Jim,

Thx for your quick reply.

I tried this....


sed 's/ENGINE=MyISAM*/TYPE=MyISAM;/' a.sql > b.sql

But it did not work.

Any idea how I can have a line-replace using a partial string match.

Thx
Vai
  #4 (permalink)  
Old 06-11-2007
vaibhavs vaibhavs is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 4
I tried this too:
sed 's/^) ENGINE=MyISAM*/TYPE=MyISAM;/' a.sql > b.sql

Inserting a ^ to indicate -- live starting with...
Did not help.

Thx
  #5 (permalink)  
Old 06-11-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
Quote:
Originally Posted by vaibhavs
Hi Jim,

Thx for your quick reply.

I tried this....


sed 's/ENGINE=MyISAM*/TYPE=MyISAM;/' a.sql > b.sql

But it did not work.

Any idea how I can have a line-replace using a partial string match.

Thx
Vai
u missed out a dot '.'

Code:
sed 's/ENGINE=MyISAM.*/TYPE=MyISAM;/' a.sql > b.sql

  #6 (permalink)  
Old 06-11-2007
vaibhavs vaibhavs is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 4
Yes Indeed!!
The missing dot worked.
Thx a lot.

regards,
Vai
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 03:55 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