Sometimes (like when writing init scripts) it is necessary to get the PID of a child process that you started, this one-liner does that by listing processes grepping for the one you created (in this case "ls"), and cutting the PID from the last one in that list:
LPID=$(ps -A | grep ls | grep -v grep | tail -n1 | cut -d\ -f2)
No comments:
Post a Comment