4 ms·
before: $ ps ax | grep myapp | grep -v grep | {...} after: $ ps ax | grep [m]yapp | {...}
by jttttt 16y ago
before:
$ ps ax | grep myapp | grep -v grep | {...}
after:
$ ps ax | grep [m]yapp | {...}
- sumeeta 16y agoHow does this work?
- Despite 16y agogrep treats "[m]yapp" as a regex, which will match "myapp" but not itself. That is, it won't match the exact string "[m]yapp" so the grep process won't show up in the listing.
- antifuchs 16y agoOh my. Do use pgrep. It's much more robust (what do you do if you have to search for a process named "0:0"?), and you don't have to use pipelines and strange regex tricks (which will fail to work on zsh with "set nomatch" if you don't quote, for example).