MrLalatg
MrLalatg

Reputation: 633

Ignore command output when grep'ing

I am trying to count occurrences of "POST" string inside docker logs

I am doing it like that:

docker logs 2c02 | grep "POST" -c

But I am getting not only the count of "POST" but also the full output of docker logs. Can I somehow ignore docker logs output?

Upvotes: 0

Views: 146

Answers (1)

Arkadiusz Drabczyk
Arkadiusz Drabczyk

Reputation: 12528

docker prints to stderr. In bash you can do:

docker logs 2c02 |& grep "POST" -c

Upvotes: 4

Related Questions