Comment: | Fix grep regex, move out the inner loop, aggregate all second-stage sed calls into one and remove usage of non-portable sed -i.
Mac OS and FreeBSD sed takes "sed -i -e <expression>" as meaning "use -e as backup suffix", they need sed -i '' -e <expression>.
We could please both FreeBSD sed and GNU sed with sed -i~ -e <expression> and then deleting the ~ file, but that's ugly.
Moreover, OpenBSD sed doesn't accept any kind of -i option.
So directly remove -i usage, and use a temporary file with .counter suffix. ~ would be tipical, but since that's also usd by some text editors, using .counter we shoulfn't clash with anyone. Note that getting a .counter file is a bug which should be reported. |