How can I convert SQL comments with -- to # using Perl?

Posted by NJTechie on Stack Overflow See other posts from Stack Overflow or by NJTechie
Published on 2010-04-29T21:19:26Z Indexed on 2010/05/02 19:38 UTC
Read the original article Hit count: 167

Filed under:
|
|

I have various SQL files with '--' comments and we migrated to the latest version of MySQL and it hates these comments. I want to replace -- with #.

I am looking for a recursive, inplace replace one-liner.

This is what I have:

perl -p -i -e 's/--/# /g'` ``fgrep -- -- *  

A sample .sql file:

use myDB;

--did you get an error

I get the following error:

Unrecognized switch: --did (-h will show valid options).

p.s : fgrep skipping 2 dashes was just discussed here if you are interested.

Any help is appreciated.

© Stack Overflow or respective owner

Related posts about perl

Related posts about regex