Ps and grep lookup eliminate grep self lookup and psgrep lookup eliminate

Source: Internet
Author: User

Ps and grep lookup eliminate grep self lookup and psgrep lookup eliminate

It is very convenient to use ps-def | grep to find the process. The last line will always grep itself.

$ Ps-def | grep dragonfly-frameworkdean 5273 5272 0 00:00:00 pts/5 newlisp. /dragonfly-framework/newlisp-redirection.lsp-http-d 8080-w. dean 5491 5229 0 00:00:00 pts/16 grep -- color = auto dragonfly-framework

You can use the grep-v parameter to exclude the grep command. Therefore, you can modify the version as follows:

$ Ps-def | grep dragonfly-framework | grep-v grepdean 5273 5272 0 00:00:00 pts/5 newlisp./dragonfly-framework/newlisp-redirection.lsp-http-d 8080-w.

Extract the process ID with awk.

Ps-def | grep dragonfly-framework | grep-v grep | awk '{print $2}' 5273


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.