1

I a trying to grep for certain string after issuing the grpck -n ALL command so when trying grpck -n ALL | grep -i format, for example, I still see the whole output and not just the lines containing the format string.

I know I could direct the output to a file and use grep on that file but it has to be an easier way.

The grpck is just an example as I have noticed other commands that don't support grep.

marked as duplicate by Jeff Schaller, user4556274, RalfFriedl, schily, Romeo Ninov Nov 2 '18 at 20:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • can you provide example input and output? – Pandya Nov 2 '18 at 12:48
  • Commands do not "support" grep in a pipeline; you're just passing the output of the command to grep. Provide both the stdout and stderr of your command, as grpck -n ALL > /tmp/grpck.out 2> /tmp/grpck.err then show the contents of each. – user4556274 Nov 2 '18 at 12:56
1

The command grpck -n ALL returns an error in my system invalid option -- 'n'. This error outputs in stderr. I think you want to redirect stderr to stdout before using grep:

grpck -n ALL 2>&1 | grep -i sort

I changed 'format' to 'sort' because my output didn't have any 'format' in it.

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