script or command to find all scripts (ksh, sh, perl, etc) in a workspace

script or command to find all scripts (ksh, sh, perl, etc) in a workspace

Post by terry433i » Sat, 06 Nov 2004 01:45:53



is there any quick way of finding all the executable scripts in a
directory structure. I'm using the following find(1) command  :
       find . -name SCCS -prune -o -follow -depth -exec file {} \;
-print | \
       grep executable|awk -F: '{print $1}'

is there a quicker way (this is really slow)

 
 
 

script or command to find all scripts (ksh, sh, perl, etc) in a workspace

Post by Stephane CHAZELA » Sat, 06 Nov 2004 01:49:56


2004-11-4, 08:45(-08), terry433iid:

Quote:> is there any quick way of finding all the executable scripts in a
> directory structure. I'm using the following find(1) command  :
>        find . -name SCCS -prune -o -follow -depth -exec file {} \;
> -print | \
>        grep executable|awk -F: '{print $1}'

> is there a quicker way (this is really slow)

Try:

find . -name SCCS -prune -o -follow -type f -exec file {} + |
  awk -F: '/executable/ {print $1}'

(note the "+" instead of ";" so that find runs as few file
instances as possible).

--
Stephane

 
 
 

script or command to find all scripts (ksh, sh, perl, etc) in a workspace

Post by aryzh » Sat, 06 Nov 2004 21:34:41



> 2004-11-4, 08:45(-08), terry433iid:
> > is there any quick way of finding all the executable scripts in a
> > directory structure. I'm using the following find(1) command  :
> >        find . -name SCCS -prune -o -follow -depth -exec file {} \;
> > -print | \
> >        grep executable|awk -F: '{print $1}'

> > is there a quicker way (this is really slow)

> Try:

> find . -name SCCS -prune -o -follow -type f -exec file {} + |
>   awk -F: '/executable/ {print $1}'

> (note the "+" instead of ";" so that find runs as few file
> instances as possible).

You may want to add  \( -perm -1 -o -perm -10 -o -perm -100 \)
to the find rules
 
 
 

script or command to find all scripts (ksh, sh, perl, etc) in a workspace

Post by Stephane CHAZELA » Sat, 06 Nov 2004 21:45:43


2004-11-5, 04:34(-08), aryzhov:
[...]

Quote:> You may want to add  \( -perm -1 -o -perm -10 -o -perm -100 \)
> to the find rules

Same as -perm +111

But shell scripts are not necessarily executables, they can be
called as: sh ./the-script.sh

--
Stephane

 
 
 

script or command to find all scripts (ksh, sh, perl, etc) in a workspace

Post by Darren Dunha » Sun, 07 Nov 2004 02:25:29



> 2004-11-5, 04:34(-08), aryzhov:
> [...]
>> You may want to add  \( -perm -1 -o -perm -10 -o -perm -100 \)
>> to the find rules
> Same as -perm +111

That's not valid syntax for Solaris 'find'.  '+' is only allowed on
symbolic permissions (like +a+x), not octal.

# /usr/bin/find /tmp -perm +111
find: -perm: Bad permission string
/usr/bin/find: path-list predicate-list

Even so, it looks to me like that would only match files will all three
execution bits set, not just one (as the previous one did).

Quote:> But shell scripts are not necessarily executables, they can be
> called as: sh ./the-script.sh

Very true.

--

Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

 
 
 

script or command to find all scripts (ksh, sh, perl, etc) in a workspace

Post by picaz » Sun, 07 Nov 2004 09:59:40


Quote:> (note the "+" instead of ";" so that find runs as few file
> instances as possible).

hi,

the + is interesting...mind explaining it further?  also, way back when,
i thought i saw a script use the {} for some sort of action...am i crazy
or not?

eg
find . -name SCCS -prune -o -follow -depth -exec file {Do Something in
Here} \;

i appreciate your time,
peter

 
 
 

script or command to find all scripts (ksh, sh, perl, etc) in a workspace

Post by all mail refus » Sun, 07 Nov 2004 10:28:19



>i thought i saw a script use the {} for some sort of action...am i crazy
>find .     ...   -exec file {Do Something in Here} \;

In find commands a "{}" represents a filename.

Scripts can put commands in {} or () .

--
Elvis Notargiacomo  master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/
    7.031: OnACPower returned value( 0x1 ) which is Equal To 0x1