24 lines
670 B
Bash
Executable File
24 lines
670 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
if [[ "$1" == "-h" || "$1" == "--help" ]]; then cat <<HELP
|
|
Get PIDs
|
|
http://benalman.com/
|
|
|
|
Usage: $(basename "$0") [processname [processname ...]]
|
|
|
|
Get the PIDs of all matching processes for all specified processnames.
|
|
If no arguments are passed, list processes by PID, TTY, USER, COMMAND.
|
|
|
|
Copyright (c) 2012 "Cowboy" Ben Alman
|
|
Licensed under the MIT license.
|
|
http://benalman.com/about/license/
|
|
HELP
|
|
exit; fi
|
|
|
|
if [ ! "$1" ]; then
|
|
ps axo pid,tty,user,command
|
|
else
|
|
args="$1"; shift; for arg in "$@"; do args="${args}|${arg}"; done
|
|
echo $(ps axo pid,tty,user,command | perl -nle"m#^\s*(\d+).*(?:$args)# && !m#.dotfiles/bin/pid# && print \$1")
|
|
fi
|