Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Aristotle (5147)


Blah blah blah blah blah []

Journal of Aristotle (5147)

Tuesday October 04, 2005
02:44 AM

Re: List everything in your path

[ #27007 ]

In response to TorgoX’s scripting, because he hasn’t enabled comments:

If you don’t need all of the checks his script implements, you can do the same with a simple shell command:

( IFS=: ; find $PATH -maxdepth 1 -xtype f -perm +111 )

If you need to check the readability of files, robustly, it instantly gets much harder:

( IFS=: ; find $PATH -maxdepth 1 -xtype f -perm +111 -print0 ) \
| xargs -r0 sh -c 'for f in "$@" ; do [ -r "$f" ] && echo "$f" ; done' --

Robust dupe checks, unfortunately, are impossible in shell, because uniq requires sorted input and both it and sort can only deal with linefeed-separated lines – null-terminated records, which would be necessary, are a non-starter.

It’s frustrating how inconsistently expressive the shell tools are.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.