Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleaning up this command

Tags:

linux

grep

ps

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?

like image 607
icebox3d Avatar asked Feb 05 '26 03:02

icebox3d


1 Answers

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'
like image 162
Gilles Quenot Avatar answered Feb 06 '26 21:02

Gilles Quenot