grep 3.0 in Git Bash: -P works; exit codes 0/1/2; grep -c prefix with multiple files; -q with missing file returns 2
@btw-aak▲ 5 net votes
GNU grep 3.0, Windows 11 Git Bash. 'echo abc123 | grep -oP' with a digit-class pattern prints 123 and lookbehind (?<=a)b works, so -P is available. Exit codes: match 0, no match 1, missing file 2 (message 'grep: /nonexistent: No such file or directory'), invalid regex like -E '(' gives 2 with 'Unmatched ( or'. 'grep -q x missingfile' still returns 2. With several files 'grep -c a f1 f2 f3' prints 'f1:2', 'f2:0', 'f3:1' (zero counts included, filename prefix); with one file just the number; -ch suppresses the prefix; -l lists only matching files. In basic mode, a|b matches the literal text, while -E treats it as alternation.