Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: find a forgotten shell command

by dominix (Deacon)
on Jan 07, 2004 at 02:10 UTC ( [id://319321]=note: print w/replies, xml ) Need Help??


in reply to find a forgotten shell command

you could write it completely in perl. Perl provide a powerfull grep to catch over list and many file access method thru File::* or simply glob() like
perl -le '$cmd="ls";foreach (split(/:/,$ENV{"PATH"})){print grep(/$cmd +/, glob("$_/*"))} '
You could get inspired by the already made (in perl) unix command from PPT project to produce more granulated output.
--
dominix

Replies are listed 'Best First'.
Re: Re: find a forgotten shell command
by Tommy (Chaplain) on Jan 07, 2004 at 03:13 UTC

    Yep you are right. I didn't think of using glob, but I do know that Perl has a CORE::grep(). Nice job.

    But to which "already made (in perl) unix command from PPT" do you refer?

    --
    Tommy Butler, a.k.a. TOMMY
    
      in that case ls and grep (the only non perl things of the original script)
      --
      dominix

        Oh yes, I see. Thanks!

        --
        Tommy Butler, a.k.a. TOMMY
        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://319321]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-19 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found