C
C
CarderCC2020-07-13 21:39:48
bash
CarderCC, 2020-07-13 21:39:48

Bash line output?

There is such a line in the bash script
procc nginx
that finds the id of the nginx processes and returns it, but returns it in one list, so you can’t use the same nice (example). You need to somehow take the ID in turn and execute the command for each separately. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2020-07-13
@carderCC

so get the whole list and process it line by line.

PIDS=`pgrep nginx`
for pid in ${PIDS[@]}; do
  echo "${pid} # поменять строку на команду"
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question