The problem is that grep -r -H -P "2\.897" . doesn’t find matches because your files likely lack the exact string "2.897". The working command, grep -r -H -P "2.897" ., succeeds by matching a wider range of strings where the dot is any character (e.g., "2,897", "2-897"). Check your files to see what they actually contain, and adjust your pattern or data accordingly to meet your regex goal