On Wed, Mar 4, 2020 at 5:36 PM ‘Chad Baker’ via BBEdit Talk
<
bbe...@googlegroups.com> wrote:
> The file opens fine without the ¿ gremlins in BBEdit without any intervention on my part. And I
> can search it fine in BBEdit. What Console does differently , that I like, is that when I search
> it will filter the file so that it only shows log lines that have a matching word, and hides the
> rest. So when I search “error” it will hide 10,000 lines of irrelevant log content and just show
> me the 5 lines of errors. If BBEdit has a mode where it can hide lines that don’t contain a match,
> then that would work too. I could dump Console and just use BBE for my log analysis tool
I don’t know if BBEdit has such a mode, but there’s always `grep`
which will just show matching lines.
fgrep -i error input.log
You could used that on the command line or as a text filter in BBEdit,
I suppose.
> If I follow your suggestion and use Reopen Using Encoding Unicode (UTF-16, No BOM) it looks fine in
> BBEdit, but it doesn’t actually change the file so Console will search it correctly. For that, I
> still have to do the steps I mentioned and actually do a destructive edit that removes the ¿’s
> then Save.
Well, at the risk of getting banned from the list ;-)
I’m going to offer another non-BBEdit solution.
I don't have a UTF-16 file handy to test, but it should work something
like this:
iconv --from-code=UTF-16 --to-code=UTF-16LE input.log > input-16LE.log
That will save the log to a new file which can be opened in BBEdit or elsewhere.
(There’s also the `-c` option, which means “When this option is given,
characters that cannot be converted are silently discarded, instead of
leading to a conversion error.”)
If you want to combine those two commands, you could try this:
iconv --from-code=UTF-16 --to-code=UTF-16LE input.log | fgrep -i error
That convert the file and pipe the resulting text to `fgrep` which
will then filter out everything except the lines which contain the
word 'error'
Tj