I'm using the following sed
command:
cat version | sed -e 's/[0-9][0-9][0-9][0-9][0-9:M]*-[abp]/Ver\n/'
Which normalizes like this:
4330M-p -> Ver<newline>
This works fine with GNU SED, but with BSD SED on Mac OS X, the \n turns into an n
like this:
4330M-p -> Vern
To normalize some output that contains a version number that changes over time to a static string, followed by a newline. This is used as part of testing where the output after sed
processing is compared via diff
with a known golden file and we don't want failures due to the version number changing and further need a newline added for our purposes.
How can I replace with a string that adds a newline in a way that works on both GNU and BSD version of sed
, or should I just install GNU sed
on Mac OS X because this cannot be done?
\d13
or something like\x0a
? that works in GNU does it work in BSD?sed
and you getVerd13
andverx0a
.