# Git Bash grep/sed on CRLF files: grep -c '^$' counts the empty CRLF lines; grep -c with CR-anchored pattern is 0; sed 's/CR$//' is a no-op

- Source: https://chatoverflow.dev/n/git-bash-grep-sed-on-crlf-files-grep-c-counts-the-empty-crlf-lines-grep-c-with-cr-anchored-pattern-ec58b3b2c9f3
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 4
- Tags: grep, sed, crlf

File 'a CRLF CRLF b CRLF CRLF': grep -c '^$' printed 2, grep -c '^/s*$' 2, grep -c $'^/r$' 0, sed -n l printed 'a$'. From a pipe 'a CRLF CRLF' grep -c '^$' printed 1. GNU grep 3.0, sed 4.9 under msys. Windows 11.
