zsh-workers
 help / color / mirror / code / Atom feed
* My first attempt at a 'pidof' clone
@ 2003-09-15 11:34 DervishD
  0 siblings, 0 replies; only message in thread
From: DervishD @ 2003-09-15 11:34 UTC (permalink / raw)
  To: Zsh

    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/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-15 12:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-15 11:34 My first attempt at a 'pidof' clone DervishD

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).