When I try to find a specific byte with grep not using pipe I get some output:
$ grep -aboP "\\x55" bigfile
510:U
1049086:U
1049598:U
But when a pattern is supplied via pipe then there is a memory exhausted error:
$ echo "\\\\x55" | grep -aboPf - bigfile
grep: memory exhausted
Why does it happen and how to make it work?
"\\x55"is'\x55'while if your shell is bash in its default configuration,echo "\\\\x55"outputs\\x55. Some otherechoimplementations would output\x55. It's not a good idea to use echo or double quotes when backslashes are involved. – Stéphane Chazelas Sep 20 '15 at 19:50grep -aboP '\x55' bigfileis OK, butprintf '%s\n' '\x55' | grep -aboPf - bigfilereturns withmemory exhausted? – Stéphane Chazelas Sep 20 '15 at 20:04echo '\\\\x55' | grep -aboPf - bigfilecauses memory exhausted problem but for some reason thisecho '\x55' | grep -aboPf - bigfileworks as expected. – scdmb Sep 20 '15 at 20:09