icebox3d
icebox3d

Reputation: 459

Cleaning up this command

I was wondering how I could reduce the amount of grep or pipes used in this command.

ps h -eo pid:1,uid,command | grep -v "screen" | grep java | grep -v "bash" | grep -v "grep"

Could it be reduced?

Upvotes: 3

Views: 73

Answers (1)

Gilles Quénot
Gilles Quénot

Reputation: 185053

Is this fit your needs ?

ps h -eo pid:1,uid,command | grep -Ev "screen|bash" | grep '[j]ava'

explanations

  • [j]ava is a known regex trick to avoid using grep -v 'grep'

Upvotes: 2

Related Questions