Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
My first attempt at a 'pidof' clone
- X-seq: zsh-workers 19080
- From: DervishD <raul@xxxxxxxxxxxx>
- To: Zsh <zsh-workers@xxxxxxxxxx>
- Subject: My first attempt at a 'pidof' clone
- Date: Mon, 15 Sep 2003 13:34:15 +0200
- Mail-followup-to: Zsh <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: Pleyades
Hi all :))
With your invaluable help I have written an small 'pidof' clone,
that currently just writes to stdout all PID's whose command name
matches $1. I'm not sure if it behaves like the original pidof, but I
just want it to tell me the PID's of some command: it is more a Zsh
exercice than a serious attempt at writing a pidof clone.
Feel free to make suggestions, corrections, bug reports, etc...
so that the script can be shorter, faster, etc...
Thanks a lot again for your help. I'm learning Zsh and I love
more than before, if possible ;)) Here comes the script:
---
#!/bin/zsh
for process in /proc/<->
do
name="${${(ps:\000:)$(<$process/cmdline)}[1]}"
[[ -z $name ]] && name="${${(f)$(<$process/status)%%State*}[1]#*[[:space:]]}"
[[ -z ${(M)name:#*"$1"*} ]] || print -n $process(:t) ""
done
# The following is just for testing ;)))
print
---
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author