[darcs-users] Re: execute permission for scripts

Ketil Malde ketil at ii.uib.no
Fri Nov 26 12:24:20 UTC 2004


Ralph Corderoy <ralph at inputplus.co.uk> writes:

> Good idea.  Is it worth checking just the magic word instead though as
> it won't match /^#!/ elsewhere in the file.

>     find . -type f -print |
>     while read f; do
>         test "`
>             dd if=$f bs=2 count=1 2>/dev/null |
>             tr -c '#!' xx;
>             echo
>         `" = '#!' &&
>         echo $f
>     done |
>     xargs chmod a+x

Isn't it simpler to do:

    for a in `find bin -type f -print`; do
        if head -n 1 $a | grep -q '^#\!'; then chmod +x $a; fi
    done

But if you want to do this, why not use 'file', and grep for the
string "executable" (which seems to be included for executable
scripts)? 

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants




More information about the darcs-users mailing list