sed GNU & BSD
2026-05-08# Cross-platform pattern: works on both GNU and BSD/macOS
sed -i'' -e 's/old/new/g' file.txt # GNU
sed -i '' -e 's/old/new/g' file.txt # BSD/macOS (note the space)
# Cross-platform pattern: works on both GNU and BSD/macOS
sed -i'' -e 's/old/new/g' file.txt # GNU
sed -i '' -e 's/old/new/g' file.txt # BSD/macOS (note the space)