I am having some issues in using an answer provided on this site for this question about a sed command to replace a blank line with two other lines of content, and it was brought up if the sed command on Mac OS (10.6.7 for me) is different. I don't think that it is, but was wondering if others on this site thought differently.
|
The behavior of shell utilities does differ in minor ways between unix variants. There are many unix variants, with a complex history. There are standardisation efforts such as the POSIX standard and its superset the Single UNIX specification. Most systems nowadays implement POSIX:2001, also known as the Single UNIX Specification version 3, with minor deviations and many extensions. The Single Unix specification is not a tutorial, but version 3 is readable if you already have an idea of what a command is doing. You can consult it to know if some feature is standard or an extension of a particular system. A majority of unix users use Linux and haven't used any other variant. Linux comes with GNU utilities, which often have many extensions to the standard. So you'll find quite a lot of code out there that works on Linux but not on other unices, because it relies on those extensions. Regarding sed, consult the sed Single Unix specification for the minimum that every system is supposed to support, the man page on your system for what your implementation supports, and the GNU sed manual for what most people out there use. One of the nonstandard extensions in GNU sed is supporting multiple commands run together. For example, this GNU sed program prints all lines containing an
This is nonstandard but commonly accepted:
Another nonstandard but common extension is the use of
|
|||
|
|
|
OS X currently comes with a FreeBSD sed from 2005. Most of the differences below also apply to other BSD sed versions. OS X's sed uses
GNU sed interprets escape sequences like GNU sed interprets GNU sed allows omitting
For example OS X's sed doesn't support the OS X's sed doesn't support One BSD option that is not supported by GNU sed is Examples of GNU sed commands that don't work with OS X's sed:
|
|||||||||||||||||||||
|