Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
sed inline -s compatible with both Linux and BSD/macOS
# 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:
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