8

I want to use the output of command:

fdisk -l | grep -i "/dev"

in my bash script.
current output of command

But the problem is that it bold and highlight/color the matched output. I don't want that. I only want to print the lines that matched the criteria.

1
  • You should unalias grep or if that's not enough, use grep --color=never
    – user313992
    Commented Dec 23, 2018 at 7:34

1 Answer 1

13

Your shell has probably a defined alias. alias grep='grep --color=auto' is rather common in ~/.bash_aliases or ~/.bashrc. You can remove the alias or replace it with

grep --color=never

You can of course use grep --color=never manually instead when you don't want colors, as it expands to grep --color=auto --color=never and the latter option overrules the former.

See grep --help, man grep or info "(grep)General Output Control" for more information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .