I saw this nice question:
Pass the output of previous command to next as an argument
and tried to get what I wanted from it but no luck.
I often want to watch my maxima/lisp process and instead of running top/htop/etc I thought I could just search for "maxima.core" and use the pid returned from that search as input to the "-p" flag for top. If it returns more than one, it is not so big of a deal.
1.) If I know the PID, I can use this:
top -p 10815 -o S -d 0
2.) To get the PID(s) I do this:
ps -fu <user> | pgrep -f maxima.core
which outputs a list like,
10814
11989
But trying to concatenate them fails for me. My tries have mostly centered around this:
<user>@<user> ~ $ top -o S -d 0 -p $(ps -fu <user> | pgrep -f maxima.core)
Also tried to incorporate the results of this: How can I get the positional parameters, starting from two, or more generally, `n`?
top -o S -d 0 -p "${(ps -fu <user> | pgrep -f maxima.core)[@]}"
but it complained of poor substitution.
I pretty much rely on bash.
pgrep
support a-d
(--delimiter
) option? BTW I doubt pipingps -fu <user>
intopgrep
is doing anything - you probably should use pgrep's own-f
and-u
options – steeldriver Jan 12 '18 at 04:26top -o S -d 0 -p "$(pgrep -d, -u <user> -f maxima.core)"
do the trick? – steeldriver Jan 12 '18 at 04:32