[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AWKing for PIDs (was Re: NetBSD style rc.d scripts?)
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: Re: AWKing for PIDs (was Re: NetBSD style rc.d scripts?)
- From: Christoph Moench-Tegeder <cmt_(_at_)_rz_(_dot_)_uni-karlsruhe_(_dot_)_de>
- Date: Fri, 31 Jan 2003 19:25:03 +0100
- Mail-followup-to: tech_(_at_)_openbsd_(_dot_)_org
## Michael Erdely (mike_(_at_)_erdelynet_(_dot_)_com):
> command = "httpd"
> PID=`ps -axo pid,ppid,command | grep -v grep \
> | grep $command | awk '{if ($2 == "1") print $1}'`
For easy use:
pidof() {
ps -axo pid,ppid,command | awk "\$3==\"$1\" && \$2==\"1\" {print \$1}"
}
in your .profile. Saves two processes, too (why run grep if you have awk
already running?)
Regards,
cmt
--
Spare Space
Visit your host, monkey.org