Last active
January 18, 2022 19:48
-
-
Save erikw/ea93364607376659bdcfb9e835e94539 to your computer and use it in GitHub Desktop.
sed inline -s compatible with both Linux and BSD/macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To be compatiable with both GNU sed and the old BSD sed that macOS uses, need to set and inplace backup extension and then remove the file. | |
# $(sed -i -e '...' file) works with GNU sed and modern BSD. However on macOS a backup file "file-e" will be created | |
# Reference: https://unix.stackexchange.com/a/131940/19909 | |
sed -i.bak -e 'expr...' file && rm file.bak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment