List:General Discussion« Previous MessageNext Message »
From:Joerg Bruehe Date:March 30 2011 1:29pm
Subject:Re: getting procedure code via mysqldump
View as plain text  
Hi all!


John G. Heim wrote:
> From: "Claudio Nanni" <claudio.nanni@stripped>
> [[...]]
> 
> 
>> In case you use a linux or unix system, to strip off the comments in
>> linux
>> bash is very easy, you can use this simple bash command:
>>
>> grep -v "^/\*" yourdumpfile.sql > yourdumpfilewithoutcomments.sql
> 
> That didn't work because there are comments embedded in the line that
> creates the procedure. For example:
> 
> /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003
> PROCEDURE `TIMETABLE_SYNC`()
> 
> That's all one line. It will probably wrap in my  message. But the line
> begins with a /* so its removed by your grep command.

No member of the "grep" family is the right tool for this, as they
always take (or ignore) whole lines.


This is a job for "sed" - try this (tested just on that single line):

  sed '1,$s=/\*![3-6][0-9]* \([^*]*\)\*/=\1 =g' <dumpfile.sql >noversion.sql


HTH,
Joerg

-- 
Joerg Bruehe,  MySQL Build Team,  joerg.bruehe@stripped
ORACLE Deutschland B.V. & Co. KG,   Komturstrasse 18a,   D-12099 Berlin
Geschaeftsfuehrer: Juergen Kunz, Marcel v.d. Molen, Alexander v.d. Ven
Amtsgericht Muenchen: HRA 95603
Thread
getting procedure code via mysqldumpJohn G. Heim30 Mar
  • Re: getting procedure code via mysqldumpClaudio Nanni30 Mar
  • Re: getting procedure code via mysqldumpMySQL)30 Mar
    • Re: getting procedure code via mysqldumpClaudio Nanni30 Mar
      • Re: getting procedure code via mysqldumpJohan De Meersman30 Mar
  • Re: getting procedure code via mysqldumpJohn G. Heim30 Mar
    • Re: getting procedure code via mysqldumpJoerg Bruehe30 Mar