Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

My first attempt at a 'pidof' clone

    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:
for process in /proc/<->
    [[ -z $name ]] && name="${${(f)$(<$process/status)%%State*}[1]#*[[:space:]]}"
    [[ -z ${(M)name:#*"$1"*} ]] || print -n $process(:t) ""

# The following is just for testing ;)))

    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