On Linux I use this to get the next two lines after the [test]
line:
sed -n '/\[test\]/{n;p;n;p}' my-file
On Mac I get:
sed: 1: "/\\[test\\]/{n;p;n;p}": extra characters at the end of p command.
Is there an expression that works on both platforms or on Mac a completely different command must be used?
Additionally, if you happen to get this error when using the -i
option without an extension:
> sed -i 's/foo/bar/g' file
sed: 1: "file": extra characters at the end of p command
In this case the solution is to explicitly set the extension to an empty string:
> sed -i '' 's/foo/bar/g' file
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