1

I have a file foo with the content:

foo

Then I perform:

grep "foo" foo > bar

produces a bar "binary" (according to the file browser) file, with the content

[01;31m[Kfoo[m[K

If I try the same with awk

awk '{ print 1ドル }' foo > bar

produces a normal text file with the content

foo

I feel I'm missing something obvious here, is this normal? Why the discrepancy between the (at least) two commands.

asked Apr 24, 2020 at 21:27
2
  • I cannot reproduce with echo foo > foo; grep "foo" foo > bar; file bar Commented Apr 24, 2020 at 21:31
  • I should've follow the clue of the color pattern characters. Commented Apr 24, 2020 at 21:42

1 Answer 1

2

The problem was simple. I had an alias of grep in my bashrc with the --color=always flag:

alias grep="grep --color=always"

The solution was just to unalias the command

unalias grep

and delete the alias from the .bashrc, then source it . .bashrc.

answered Apr 24, 2020 at 21:46

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.