How can I sed or regex this out
-
I have two files,
dba.sql
anddb2.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..
-
@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'
-
@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'
-
That did not work. But inside VSCode I did this.
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. -
@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’
-
So single quotes seem broken??
It’s
-
@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 /.