I'm trying to adapt the answer from https://stackoverflow.com/a/66365284/1236401 that adds control flow to provide match status code:
cat file.txt | sed 's/1/replaced-it/;tx;q1;:x'
It works as expected on Ubuntu and Alpine, but fails on Mac OSX (11.6
), using any shell.
sed: 1: "s/1/replaced-it/;tx;q1;:x": undefined label 'x;q1;:x'
All references I could find to sed
misbehaving on OSX were for in-place file edit, which is not the case here.