I will try to break this by answering your question in pieces.
The first part we'll look at is sed 's/,$//' . I will not explain briefly the sed command, but please see the GNU sed manual for more information. 's/,$//' tells sed to look for any commas at the end of the line and does not replace them with anything. This removes all the commas from the end of each line on standard sed input.
The next snippet we'll look at is tr "\\n" "," . Again, tr can do many things, but its goal is to convert characters. See tr man page for more details. This usage should include all UNIX newline characters ( \n ) with a comma. \ must be escaped with an extra \ , because the command line will treat \n as a new line and break the command.
Next is pgrep process-name . For completeness, here is the pgrep man page. pgrep simply prints the process identifier (pid) of any running process that matches the selection criteria to the standard one. Each pid will be printed on a separate line. Here we are looking for the pid of the process-name command.
Now for the pipe ( | ). This creates a new process and sends everything that is printed to the standard standard in the new process.
Let's look at the teams to understand how the pipe works. pgrep process-name | tr "\\n" "," pgrep process-name | tr "\\n" "," will print all pid process-name matches in a standard way, which is passed to the standard input of the tr process. tr "\\n" "," | sed 's/,$//' tr "\\n" "," | sed 's/,$//' converts all the lines of a newline from its standard to commas and prints the result to its standard output, which is passed to the new process sed 's/,$//' .
So the whole pgrep process-name | tr "\\n" "," | sed 's/,$//' pgrep process-name | tr "\\n" "," | sed 's/,$//' pgrep process-name | tr "\\n" "," | sed 's/,$//' will print a pid line with a space for any running process that has the name process-name .
Two more parts: top -p and backward labels (``). Backticks creates a new process that runs commands inside and replaces its standard before computing the entire team. For example:
echo `echo "Hello, World!"`
displays Hello, World! .
Finally, top -p accepts a list of messages and reports of various information, such as runtime, memory usage, and nice value. A more detailed explanation can be found on the page.