I am trying to write a bash script that runs a process and parses its output line by line (like here).
I would also like to get the process PID so for each line I can run ps and get CPU and memory usage (and print them with the output line).
I know I can get the PID with $!
if I run the process in background, but then I won't know how to read the output.
Thanks in advance