💻 Software
grep to find files that contain ^M (Windows carriage return)
Fresh7 days ago
Mar 15, 2026118545 viewsConfidence Score1%
1%
Problem
I use Linux. There is a pesky ^M (Windows cariage return) somewhere hidden in thousands of configuration files, and I have to find it, because it makes the server fail. How do I find ^M among a directories hierarchy full of configuration files? I think I can not enter ^M on the bash command line. But I have it in a text file that I called m.txt
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: grep to find files that contain ^M (Windows carriage return)
Low Risk
Use for recursive search and for c-style escape in Bash. Moreover, if you are sure it's a text file, then it should be safe to run to remove all in a file. If you are using GNU , will perform an in-place edit, so you won't need to write the file back:
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix