I am looking to see if a specific process is running as a specific user. For which I can do this
ps --no-headers -C command -o user | grep user
Which is pretty neat, it however gets slightly ugly if I then want to print the arguments (which may interfer with the grep for the username!)
ps --no-headers -C command -o user,pid,comm | egrep \^user
This would get even messer if I didnt want the user as the first or last column. What would be neater is if I could specify the -C and -U options in PS like this
ps --no-headers -C command -U user -o pid
This however doesnt work as the two clauses act as ORs rather than ANDs. Is there some function of 'ps' that I'm missing, or maybe another neat one liner I could use? Cheers!