You are not logged in.
Some how a log file I want to grep I think contains some illegal characters which makes grep think it's a binary and thus I cannot grep it. What is a good strategy to clean it to pure text? Googling hasn't turned up anything that works. I was thinking something in sed but again, found nothing that works. Thanks.
grep -i banks /scratch/text.log
grep: /scratch/text.log: binary file matchesLast edited by graysky (2021-08-05 00:52:06)
Offline
grep -a ?
-a, --text
Process a binary file as if it were text; this is equivalent to the --binary-files=text option.
Offline
grep think it's a binary and thus I cannot grep it.
Na. The problem is you cannot grok it.
grep -i -a banks /scratch/text.logBut if you ever really do need to clean out some characters, I'd use something like the following:
tr -d -c '\t-~' < dirty > clean
# or
tr -d -c '\000-\177' < dirty > cleanEDIT: too slow ... I was looking for a :asci: character class for tr, but it may not have one.
Last edited by Trilby (2021-08-04 22:51:05)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
strings /path | grep 'pattern'Offline
That -a switch is excellent, thanks.
Trilby - Your tr command fixed it, thanks to you as well.
Offline