5 ms·
Modern Linuxes have pgrep to help avoid the inevitable "lol, the grep process I fired will match" issue that results in having to filter that out as well with y
by devonkim 10y ago
Modern Linuxes have pgrep to help avoid the inevitable "lol, the grep process I fired will match" issue that results in having to filter that out as well with yet another program.
- pacaro 10y agoGood to know, I always just `ps aux | grep [j]ava`
- smhenderson 10y agoYeah, I always felt having to type the extra bit was strange, like maybe grep could have a switch to say "don't find grep" but I guess having a switch for such a specific use case, grepping processes, is overkill. Anyway, it's just a reflex now to always: ps aux | grep <program> | grep -v grep
- amyjess 10y agoYou can also surround each character in the program's name with square brackets. ps -ef | grep [p][r][o][g][r][a][m]
- jpitz 10y agoYou only need surround one character.
- smhenderson 10y agoYes, I never knew that. But I saw it in another post and as the sibling post mentions it's enough to surround just the first character with the brackets... This is why I love HN, I learn stuff I never knew I wanted to know!
- nocman 10y agoOne problem with pgrep is it has no option to ignore case. Yes, I do sometimes have processes with camel-cased names which I may or may not remember exactly. So you: ps auwx | grep -i {lc-version-of-camel-cased-name}