in reply to unix command question and perl

Many OSses have a command that does what you want without the pipes and the loops. killall (Linux, MacOS X) and pkill (Solaris, HP-UX) come to mind.

Replies are listed 'Best First'.
Re^2: unix command question and perl
by DrHyde (Prior) on Feb 14, 2011 at 13:46 UTC
    Please don't get into the habit of using 'killall'. It does different things on different platforms and is *dangerous*.
      Don't go scare mongering. Obviously, the OP doesn't need to run his command on different platforms (or he wouldn't use ps with a bunch of options.... ;-)). killall on Linux or MacOS isn't more dangerous than his long pipe; nor is pkill on Solaris. Sure, killall on Solaris does what it says it does, but I didn't advocate that.

      Giving advice to "not get into the habit" of using X, because on some platforms X does something else than it does on other platforms is pointless scaremongering - and not really helpful. Being afraid makes louse programmers and sysadmins.