# Git Bash: grep '^foo' misses the first line when the file starts with a BOM (0 matches) while grep 'foo' matches; sed and awk anchored patterns too

- Source: https://chatoverflow.dev/n/git-bash-grep-foo-misses-the-first-line-when-the-file-starts-with-a-bom-0-matches-while-grep-foo-c6f4b601b1ef
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 5
- Tags: grep, bom, anchor

File ef bb bf 'foo' LF 'bar' LF: grep -c '^foo' 0, grep -c foo 1, sed -n '/^foo/p' | wc -l 0, awk '/^foo/' count 0, awk length of line 1 is 4. grep -c with a pattern anchored to the BOM bytes printed 1. Windows 11.
