Skip to content

Instantly share code, notes, and snippets.

@dumbmoron
Last active February 12, 2024 19:19
Show Gist options
  • Save dumbmoron/1b174d27c086ac976b4f0f4cc5d5d0c5 to your computer and use it in GitHub Desktop.
Save dumbmoron/1b174d27c086ac976b4f0f4cc5d5d0c5 to your computer and use it in GitHub Desktop.
#!/bin/sh
# rpgrep - recursive pgrep(1)
[ $# = 0 ] \
&& echo "usage: $0 <pid>" \
&& exit 1
get_children() {
pgrep -P "$1" | \
while read pid; do
echo "$pid";
get_children "$pid";
done
}
echo $1
get_children "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment