A simple Ruby script to kill all processes with a specific name.
Looking back on what I’ve done after a night’s rest with mixed horror and amusement, it seems this script is completely and totally useless, unless you’re looking for a half-hearted reimplementation of killall in Ruby. Why the hell did I write this?
Download the script to /usr/bin (or wherever) and chmod +x ./killevery
#!/usr/bin/ruby def killevery(victim, options) processes = `ps -A | grep #{victim}`.scan(/(d+) .*/) if processes.length > 0 puts "Killing #{processes.length} processes named #{victim}" processes.each { |p| print `kill #{options} #{p}` } else puts "No processes are named #{victim}." end end if $*.length < 1 puts "Kill every process named >name<. Takes the same parameters as killall" else killevery($*.pop, $*.join(' ')) end






The -signs are converted to their HTML entities (> and <) in your post. I accidentally replaced the < with a > so it wouldn’t work here at first.
Now it seems to work fine, nice script !