Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created April 19, 2012 05:23
Show Gist options
  • Save jclulow/2418802 to your computer and use it in GitHub Desktop.
Save jclulow/2418802 to your computer and use it in GitHub Desktop.
ptree for linux
#!/bin/bash
if [[ $# -gt 0 ]]; then
if expr $1 : '^[0-9]*$' > /dev/null; then
ARGS="-p $1"
shift
while [[ $# -gt 0 ]]; do
ARGS="${ARGS},$1"
shift
done
else
ARGS="-u $1"
fi
else
ARGS="-e"
fi
ps -H -o pid,cmd $ARGS | sed -n -e 's/^ *\([0-9]*\) \( *\)\(.*\)/\2\1 \3/' -e '2,$p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment