Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: file test results not as expected

by Fletch (Bishop)
on Nov 22, 2020 at 03:13 UTC ( [id://11123999]=note: print w/replies, xml ) Need Help??


in reply to file test results not as expected

Using Path::Tiny

$ perl -MPath::Tiny -E 'for my $dir ( split(/:/,$ENV{PATH}) ){say for +grep {-f -x $_} path($dir)->children }'

Also depending on your shell it may already have these cached. For instance ZSH provides a commands hash which maps from the command name to the corresponding file name.

$ print -l "${(@k)commands}" | sort | tail zipinfo zipnote zipsplit zless zmore zmqshell.py znew zprint zsh zsh-5.8 $ print $commands[zsh] /usr/local/bin/zsh

Edit: Dump the ZSH cache with for i in "${(@onk)commands}" ; { printf "%20s\t%s\n" "$i" "$commands[$i]" } | less; of course keep in mind that the commands parameter shows only what would be found first on PATH; if you're looking for exhaustive (including things with matching names shadowed in subsequent directories) you'd want the other solutions.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-19 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found