0

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.

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

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.