On macOS version 11.2.2.
$ which sed /usr/bin/sed
sed version: 4.8 SED(1)
When I run this code on Ubuntu, it works.
$ sed '1~2d' sample.txt two four six
But when I run this on macOS, both in zsh and bash, it won't work.
$ sed '1~2d' sample.txt sed: 1: "1~2d": invalid command code ~
Why doesn't it work on macOS?
How can I make it work?
[Update] When I run man sed | grep GNU, it outputs telling that This is a GNU extension.