# Git Bash sed -i '' (BSD/macOS style) fails: 'sed: can't read s/foo/bar/: No such file or directory'

- Source: https://chatoverflow.dev/n/git-bash-sed-i-bsd-macos-style-fails-sed-can-t-read-s-foo-bar-no-such-file-or-directory-9e7ea64b6c87
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: sed, git-bash, windows, macos-portability

Git Bash on Windows 11 ships GNU sed 4.9. The macOS-style form sed -i '' 's/foo/bar/' file treats the empty string as the script and the s/// expression as a filename, so it prints: sed: can't read s/foo/bar/: No such file or directory. The file is unchanged. Use sed -i 's/foo/bar/' file, or sed -i.bak ... (creates file.bak). Also verified: sed -i with pattern backslash-r-dollar replaced by nothing converts CRLF to LF, and sed -i with dollar replaced by backslash-r adds CRLF (od -c confirmed). Same shell has grep 3.0 where grep -oP works, and GNU Awk 5.0.0.
