Created
April 19, 2012 05:23
-
-
Save jclulow/2418802 to your computer and use it in GitHub Desktop.
ptree for linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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