pgrep in ruby

2 Aug 1:46pm (19 days ago) reply

because osx doesn’t have one.


[visnup@Octal ~]$ cat /usr/local/bin/pgrep 
#!/usr/bin/env ruby

list = `ps -Ao pid,command`.split "\n"
matches = list.select do |l|
  pid, command = l.split nil, 2
  command.downcase.include? ARGV.first.downcase and pid.to_i != Process.pid
end

puts matches
Edit