Filter the process PID using SED and cut.

Source: Internet
Author: User
All maintenance cluster users know that they often need to start or stop processes on all nodes. This requires that the PID be obtained first, and the PID can be obtained through PS output, however, information except the PID must be filtered out. This can be done in combination with SED and cut:

Sed supports extended regular expression. You only need to use the-r option in the SED command, for example:

PS aux | grep ypbind | sed-r's // + // G'

This command can be used to cut all spaces in the PS output information into one space, and then:

PS aux | grep ypbind | sed-r's // + // G' | cut-F2-d ""

You can use cut to retrieve the PS fields one by one, because-d "in cut specifies that Delimiter is a space rather than multiple spaces, use sed to convert multiple spaces into one space. In this way, cut will be processed.

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.