Assuming I know the process PID and want to search in ps-A, how do I do this? I tried to do this:
echo "Enter PID to search: "
read PID
search=$(ps -A | grep -v PID | awk '{print $1}')
This brings me back with a long list of PIDs. So, how can I use each individual output value and do:
if [ "$PID" = "*each_value_in_search_list*" ]; then
........
In this case, I am trying to compare what the user types with the output of my command, so how do I do this? Am I doing the right way first? Or is there any other way to do this?
Thanks for your help, everyone who answered this question. (
source
share