Skip to content

Instantly share code, notes, and snippets.

@michaelwclark
Created November 16, 2012 22:43
Show Gist options
  • Select an option

  • Save michaelwclark/4091594 to your computer and use it in GitHub Desktop.

Select an option

Save michaelwclark/4091594 to your computer and use it in GitHub Desktop.
Gets PID(s) of matching argument query if there are any and outputs them nicely with Echo.rb (git://gist.github.com/4091319.git).
#!/usr/bin/env ruby
class GetPid
#Main
ARGV.each do |arg|
puts `Echo.rb bold red "Query: #{arg}"`
pids=`ps aux | grep -v grep | grep #{arg} | awk '{print $2}'`.split("\n")
pids.each do |pid|
puts `Echo.rb bold blue "\tPID: #{pid}"`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment