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.
1 Answer 1
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
.
echo foo > foo; grep "foo" foo > bar; file bar