Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Good job ilkkachu! Commented Aug 25, 2016 at 15:21
  • GNU sed accepts ; as a command separator. BSD sed (as found on OS X, for example) requires newlines. Commented Aug 25, 2016 at 15:34
  • 2
    @Kusalananda, ; can be used to separate most commands in all sed implementations, but cannot be used after certain commands like :, b, }, w or # in some implementations. For instance b a;b is meant to branch to the a;b label in POSIX seds (that will change in the next POSIX spec version though), and in # foo; bar, that ; is part of the comment in all implementations, even GNU sed (same for w file;foo.txt). sed -ne '/CSP/{n;s/./;/3;p;}' should work in all sed implementations even if IIRC POSIX currently doesn't allow it (a bug in the spec) Commented Aug 25, 2016 at 15:47
  • I did test that example with the sed on OS X, actually, since I expected there was some trickery with the semicolon. Commented Aug 25, 2016 at 15:59