Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Last active September 14, 2015 20:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristopherjohnson/2fd39fe152daa834646a to your computer and use it in GitHub Desktop.
Save kristopherjohnson/2fd39fe152daa834646a to your computer and use it in GitHub Desktop.
Bash function to print process info for matching process name
# psg NAME
function psg {
processes=$(pgrep $@)
if [ -z "$processes" ]; then
echo "No matches"
else
ps $processes
fi
}
@kristopherjohnson
Copy link
Author

Example:

kjmacbook:~ $ psg core
  PID   TT  STAT      TIME COMMAND
   75   ??  Ss     0:04.67 /usr/libexec/coreduetd
  149   ??  Ss     0:02.95 /System/Library/CoreServices/coreservicesd
  197   ??  Ss     0:00.03 /usr/libexec/corestoraged
  327   ??  Ss     0:00.05 /System/Library/PrivateFrameworks/CoreSymbolication.framework/coresymbolicationd
  373   ??  Ss     0:06.47 /usr/sbin/coreaudiod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment