0

Using MKS SED for Windows, this;

TYPE Q:\temp\allrequired.M3U | SED -En "/\\Curtain\\/!b;s_^.._Q:_p"

fails with

sed: label ";s_^.._Q:_p" not found in script

How can I get the b command to respect the command separator ";" and hence act with no label?

I'm aware there are alternatives to b in this case. This is demo of the b issue.

Currently I'm using this clumsy workaround:

TYPE Q:\temp\allrequired.M3U | SED -En -e "/\\Curtain\\/!b" -e "s_^.._Q:_p"
ChrisJJ
  • 2,191
  • 1
  • 25
  • 38
  • 1
    as per https://www.gnu.org/software/sed/manual/sed.html#Multiple-commands-syntax, separating `b` with `;` is GNU sed extension.. check manual of mks sed... using `-e` would be the only way perhaps – Sundeep Aug 21 '17 at 01:51
  • What do you even need the `!b` for? If the line doesn't match the pattern, the corresponding command is skipped. This should be equivalent: `/\\Curtain\\/s_^.._Q:_p` – Benjamin W. Aug 21 '17 at 01:56
  • @Sundeep, Where does that linked page say separating b with ; is GNU sed extension? MKS SED does not document ;. – ChrisJJ Aug 21 '17 at 07:48
  • @Benjamin, !b lets me add further commands inside the same conditional, rather than repeat the address. – ChrisJJ Aug 21 '17 at 07:49
  • below the second example blocks.... `The {,},b,t,T,: commands can be separated with a semicolon (this is a non-portable GNU sed extension).` – Sundeep Aug 21 '17 at 08:08
  • @Sundeep, Thanks. Glad I'm not using teh GNU version then - that semicolon after b would inadvertently break compatibility :(. That version should have a non-portable warning on "Labels used in b,t,T,: commands are read until a semicolon." too. – ChrisJJ Aug 21 '17 at 10:57

0 Answers0