ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How can I sed or regex this out

    IT Discussion
    regex sed
    3
    7
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by JaredBusch

      I have two files, dba.sql and db2.sql scripts that were created and I want to remove something from some comments that make it seem like I have way more difference than I do.

      I am looking at these in VS Code on my Fedora 25 Desktop.

      I have a lot of these.

      /****** Object:  Schema [DataSync]    Script Date: 11/30/2017 10:28:57 AM ******/
      /****** Object:  UserDefinedFunction [dbo].[FiscalMo]    Script Date: 11/30/2017 10:24:23 AM ******/
      /****** Object:  Table [dbo].[QuoteHeader]    Script Date: 11/30/2017 10:29:06 AM ******/
      

      I want them to match. SO the time needs gone. or even the entire "Script Date" bit.

      Like this would be great. but really anything so long as they match.

      /****** Object:  Schema [DataSync] ******/
      /****** Object:  UserDefinedFunction [dbo].[FiscalMo] ******/
      /****** Object:  Table [dbo].[QuoteHeader] ******/
      

      Tired brain is tired..

      1 Reply Last reply Reply Quote 2
      • RomoR
        Romo
        last edited by

        @jaredbusch said in How can I sed or regex this out:

        ****** Object: UserDefinedFunction [dbo].[FiscalMo] Script Date: 11/30/2017 10:24:23 AM ******

        sed 's/Script.*M //g'
        
        JaredBuschJ 1 Reply Last reply Reply Quote 1
        • JaredBuschJ
          JaredBusch @Romo
          last edited by JaredBusch

          @romo said in How can I sed or regex this out:

          @jaredbusch said in How can I sed or regex this out:

          ****** Object: UserDefinedFunction [dbo].[FiscalMo] Script Date: 11/30/2017 10:24:23 AM ******

          sed 's/Script.*M //g'
          

          I need at least one * and the / to close.

          So this?

          sed 's/Script.*M /\ \*\//g'
          
          stacksofplatesS RomoR 2 Replies Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch
            last edited by

            That did not work. But inside VSCode I did this.
            0_1512103858329_548119b8-b7b3-4e48-a1bc-87d5156f45c9-image.png

            Inside there is took the .* to mean replace that was search and everything after it. So that worked for this.

            No idea WTF I am donig wrong with sed but I am too tired to care.

            1 Reply Last reply Reply Quote 0
            • stacksofplatesS
              stacksofplates @JaredBusch
              last edited by stacksofplates

              @jaredbusch said in How can I sed or regex this out:

              @romo said in How can I sed or regex this out:

              @jaredbusch said in How can I sed or regex this out:

              ****** Object: UserDefinedFunction [dbo].[FiscalMo] Script Date: 11/30/2017 10:24:23 AM ******

              sed 's/Script.*M //g'
              

              I need at least one * and the / to close.

              So this?

              sed 's/Script.*M /\ \*\//g'
              

              It’s easier to use a different delimiter like |. On mobile so I’ll do a simple example to replace /path1/ with /path2/

              sed ‘s|/path1/|/path2/|g’
              
              1 Reply Last reply Reply Quote 0
              • stacksofplatesS
                stacksofplates
                last edited by

                So single quotes seem broken??

                It’s

                1 Reply Last reply Reply Quote 0
                • RomoR
                  Romo @JaredBusch
                  last edited by Romo

                  @jaredbusch said in How can I sed or regex this out:

                  @romo said in How can I sed or regex this out:

                  @jaredbusch said in How can I sed or regex this out:

                  ****** Object: UserDefinedFunction [dbo].[FiscalMo] Script Date: 11/30/2017 10:24:23 AM ******

                  sed 's/Script.*M //g'
                  

                  I need at least one * and the / to close.

                  So this?

                  sed 's/Script.*M /\ \*\//g'
                  

                  You are escaping seds delimiters with that.

                  Changing the delimiters for better clarity:

                  sed 's|Script.*M ||g' 
                  

                  From Script to M + space, replace with space,. It keeps all your * and the final /.

                  0_1512131437191_Screenshot_20171201-062914.png

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post