tricky search replace: Pls help.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tricky search replace: Pls help.
# 1  
Old 06-11-2007
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  
Old 06-11-2007
One way:
Code:
sed 's/ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;/TYPE=MyISAM;/' oldfile > newfile

# 3  
Old 06-11-2007
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  
Old 06-11-2007
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  
Old 06-11-2007
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  
Old 06-11-2007
Yes Indeed!!
The missing dot worked.
Thx a lot.

regards,
Vai
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url=https://qa.east.corp.com/prop/end west.url=https://qa.west.corp.com/prop/end south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies

2. UNIX for Dummies Questions & Answers

Help with search and replace or search only of / in vi

Hi all, I am editing a config file in vi that has a / on it. At the moment, search and replace looks alright as am able to use a # as a temporary separator, i.e. :,$s#/u01/app#/u02/app#g For doing a search, I have to escape the / do. So if I want to search for /u01/app, I am having to do... (2 Replies)
Discussion started by: newbie_01
2 Replies

3. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

4. Shell Programming and Scripting

Search and Replace

Hi!!! I have following xml file with 3 sections. aaa1bbb-ccc default aaa1bbbdd default 0 11 23 * * aaa2bbb-ccc default aaa2bbbdd default 0 11 23 * * aaa3bbb-ccc default aaa3bbbdd default 0 15 23 * * (15 Replies)
Discussion started by: tdev457
15 Replies

5. Shell Programming and Scripting

sed replace not work Pls. help me

sed replace not work Pls. help me I used sed command in my file 66875964560@1982589 90825890001@90825890001@3@15/12/2007 14:25:14@22/03/2010 6:06:13@20/01/2010 3:28:39 66873064490@1925912 90259120001@90259120001@5@02/04/2009 1:51:31@30/10/2009 3:08:34@13/09/2009 8:24:33... (3 Replies)
Discussion started by: ooilinlove
3 Replies

6. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

7. Shell Programming and Scripting

pls help! complex find and replace

help pls... i would like to change this CURVE2 565489 789458 1258649 random data here... CURVE2 565489 568795 6548921 random data here... CURVE2 565489 123598 6446259 random data here... CURVE2 565489 672956 2489657 into this CURVE2 565489 586423 1258649 random data here...... (2 Replies)
Discussion started by: lakanino
2 Replies

8. Shell Programming and Scripting

search and replace

i have the following create table definition ,the shell script has to search for the first column name of the create table definition in the file and explicitly add primary index (first column name) at the end i.e before ";" it has to search through all the files (say 20 files) and has to... (1 Reply)
Discussion started by: a.suryakumar
1 Replies

9. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

10. Shell Programming and Scripting

search and replace

hi all, the problem is like this...... i setup a file (Env.txt) which handles all the values. NAME1=xxxxxx, where xxxxx is the value NAME2=xxxxxx GGGGG=uusufu I have 6 files, where i will append the values from env.txt. These files has no specific format. all i want is to append the... (1 Reply)
Discussion started by: tungaw2004
1 Replies
Login or Register to Ask a Question