#!/bin/bash # # de-execute all executable files that are either zero width or don't have a shebang (Magic Line) # # note: no explicit non-binary check ( -not -exec grep -vIq . "{}" \; ) # echo -n "before: "; find . \( -name '.git' -o -name 'bin' \) -prune -o -type f -executable -print | wc -l find . \( -name '.git' -o -name 'bin' \) -prune -o -type f -executable \ \( -size 0 -o -exec /bin/bash -c 'head -n 1 {} | grep -vq ^#!' \; \) -exec chmod -x {} \; echo -n "after: "; find . \( -name '.git' -o -name 'bin' \) -prune -o -type f -executable -print | wc -l