ack3 icon indicating copy to clipboard operation
ack3 copied to clipboard

redirect ack output into a file results in non-printable characters appearing in the output file

Open engrvns opened this issue 3 years ago • 1 comments

Hi ack team

When do redirect ack output into a output file there are non-printable characters appearing in the output file as below - [0m:[35m1077[0m:

I do not see this issue with grep. Is there a way this can be avoided...?

engrvns

engrvns avatar Apr 27 '21 17:04 engrvns

How are you calling ack? Please give an exact command line you're using. Also, do you have an .ackrc file somewhere?

Chances are, you're adding --color to the command line options, or you have --color in an .ackrc file. You can use ack --dump to see where you might be bringing in options you don't mean to be.

petdance avatar Apr 27 '21 18:04 petdance

That's correct. O am adding --color option

engrvns avatar Sep 26 '22 20:09 engrvns

If you add the --color option, then you will get color codes in your output, even if you are redirecting to a file.

By default, ack will output color codes to the screen, but not when redirecting to a file. So if you take out the --color, you should get the results you want.

petdance avatar Sep 26 '22 20:09 petdance

So they should be able to put --no-color on the command line when redirecting, right? That will override the .Ackrc file setting

(Also, the same less -iR used with --pager= should work to view the saved color in the files. )

n1vux avatar Sep 26 '22 22:09 n1vux

Yes, --no-color works as well.

petdance avatar Sep 26 '22 22:09 petdance

Yes --no-color worked in redirection to avoid non-printable chars.

engrvns avatar Sep 28 '22 17:09 engrvns