Prior to today, despite growing comfort with many and varied Linux commands, I have not attempted to understand some of the components of a useful command from another StackOverflow posting to filter the top
command to certain processes (by process name):
top -p `pgrep process-name | tr "\\n" "," | sed 's/,$//'`
This top
command contains various syntactic components. I could look up each component in turn (and some are obvious, such as the pipe command - though I'm still not 100% comfortable with the distinction between the pipe |
and redirection >
).
However, because filtering the top
command by process name is often useful, and because the command is on its face clearly not trivial from a syntax perspective, it would be useful for me (and perhaps others) to have a reference to an actual (brief) explanation for all of the pieces of this command, in one place.
Therefore, my question is the following.
What is a brief explanation of all of the components of the above top
command (that filters the output of top
by process name)? I would appreciate leaving no piece of syntax out, if even for just a brief mention. Thanks!