I’ve seen someone use command:
ps -ef | grep [h]ttpd
and Output is:
apache 25125 31006 0 21:54 ? 00:00:00 /usr/sbin/httpd apache 26869 31006 0 22:04 ? 00:00:00 /usr/sbin/httpd apache 27349 31006 0 22:07 ? 00:00:00 /usr/sbin/httpd apache 27696 31006 0 22:09 ? 00:00:00 /usr/sbin/httpd apache 28534 31006 0 22:14 ? 00:00:00 /usr/sbin/httpd root 31006 1 0 16:16 ? 00:00:00 /usr/sbin/httpd apache 31011 31006 0 16:16 ? 00:00:00 /usr/sbin/httpd
2 brackets surrounding the letter “h” where the grep to do?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
It’s a trick to prevent the grep command itself from appearing in the ps output.
[...] is a character class specification, i.e. [ab2] matches exactly one character that must be a, b or 2. [h] matches only exactly h.
The trick is that [h]ttp matches http, but it doesn’t match itself.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0