Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: kill and pid files
- X-seq: zsh-users 907
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxxxxxxxxxxx>
- To: luomat@xxxxxxxx
- Subject: Re: kill and pid files
- Date: Thu, 19 Jun 1997 02:42:34 -0400 (EDT)
- Cc: rstone@xxxxxxxxxxxxx, zsh-users@xxxxxxxxxxxxxxx
- In-reply-to: <Pine.NXT.3.96.970618161237.19016A-100000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> from Timothy J Luoma at "Jun 18, 97 04:16:13 pm"
> well, I don't have the file part, but I use this
>
> pid () {
>
> for i in $*
> do
> echo `/bin/ps -auxwww | grep -v grep |
> grep -w $i | awk '{print $2}' | tr -s '\012' ' '`
>
> done
>
> }
Oh, this is a really overcomplicated solution for a simple problem. How
about this:
pid () {
local i
for i
do
ps acx | sed -n "s/ *\([0-9]*\) .* $i *\$/\1/p"
done
}
Under Linux, you can even do that without ps or sed:
pid2 () {
local i
for i in /proc/<->/stat
do
[[ "$(< $i)" = *\((${(j:|:)~@})\)* ]] && echo $i:h:t
done
}
Zoltan
Messages sorted by:
Reverse Date,
Date,
Thread,
Author