is this a bug in cygwin GNU sed 4.4 when run from a cmd window?
this works
C:\>echo asdf| sed "s/a/w/"
wsdf
C:\>
this works (apart from that the output isn't quite right in that it shouldn't have a space before the 'den')
C:\>echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1 p/"
den VID_abc p
C:\>
these don't work at all. the output should have no space at the start and should say den...
C:\>echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1\2 p/"
pn VID_abc_def
C:\>echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1\2 p/"
pen VID_abc_def
C:\>echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1\2 p/"
pden VID_abc_def
C:\>echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1\2 p/"
p den VID_abc_def
C:\>
this works
C:\>echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1 p/"
den VID_abc p
C:\>
as soon as I add the \2 then it doesn't work and no longer starts with 'den'
C:\>echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1\2 p/"
pn VID_abc_def
C:\>
Yet from a cygwin window it works fine
$ echo VID_abc_def|sed -r "s/(VID.*)(_def.*)/den \1\2 p/"
den VID_abc_def p
I'm not sure that there is a sed for windows. Gnuwin32 stuff is all old. Cygwin sed is more up to date but doesn't seem to work from cmd.. I may stick with perl Perl for matching with regular expressions in Terminal? and https://stackoverflow.com/questions/4794145/perl-one-liner-like-grep
C:\>echo VID_abc_def|perl -0777 -pe "s/(VID.*)(_def.*)/den \1\2 p/"
den VID_abc_def p
C:\>
There doesn't seem to be a reliable up to date sed for windows at the moment and hasn't been for years.
$ sed --version
sed (GNU sed) 4.4
Packaged by Cygwin (4.4-1)
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: </...>.
and
C:\>sed --version
sed (GNU sed) 4.4
Packaged by Cygwin (4.4-1)
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <...>.
C:\>