I'm having troubles in doing simple stuff with grep in my Mac. I'd like to rename a file, and for that I use grep and sed.
grep
, it works fine.grep
, it doesn't work: mv shows a weird error.For what I understand, the reason may be the colored grep I am using, and then mv
uses not the filename, but the code for displaying the colored filename in the console (as elm
content is a colored yum.txt
, instead of a normal one).
Is this the reason? What can I do?
You are right, those strange characters are indeed color codes. You can search for the --color=
option either in GREP_OPTIONS
environment variable (printenv
) and/or your user defined aliases.
Then just change --color=always
to --color=auto
; with the --color=auto
option set, grep
should display color codes only when the standard output is connected to a terminal and plain text otherwise.