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?
It's prevent the grep command itself from appearing in the ps output.
– lotusirous Jun 09 '13 at 10:44ps -ef|grep http
, thegrep
command itself will sometimes appear in the output, which is not desirable. With[h]ttp
, the grep command filters itself out because of the above. – Mat Jun 09 '13 at 10:45bash
orgrep
? – lotusirous Jun 09 '13 at 10:52[h]ttp
glob pattern in the current directory (that would be a file called exactlyhttp
) - in that case, the trick will fail since the shell will expand the glob. usegrep '[h]ttp'
to prevent this. – Mat Jun 09 '13 at 10:54