In sed, it is fairly common to use multiple commands separated by semi-colons:
$ sed -e '/re/{s//replace/p; q;}
However, the standard (eg http://pubs.opengroup.org/onlinepubs/9699919799/ ) only allows for newlines as a separator:
$ sed -e '/re/{ s//replace/p q }
Are there many common implementations of sed still in use that do not allow the semi-colon? IOW, can a sed script intended to be portable use semi-colons?
From the POSIX specification of sed
:
Command verbs other than {, a, b, c, i, r, t, w, :, and # can be followed by a
<semicolon>
, optional<blank>
characters, and another command verb. However, when the s command verb is used with the w flag, following it with another command in this manner produces undefined results.
So most commands, besides those mentioned above, can be separated by a semicolon.
/[^\{abcirtw:#];[[:space:]]*/
:-)
Tricky one... Only reference I could find about this is in the sed-faq chapter 6.8.1
Most versions of sed permit multiple commands to issued on the command line, separated by a semicolon (;).
The only reference towards ;
not working is for HHSED
, see Chapter 7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With