diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/chmod-x.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/chmod-x.sh b/bin/chmod-x.sh new file mode 100755 index 0000000..fe8ae9a --- /dev/null +++ b/bin/chmod-x.sh @@ -0,0 +1,30 @@ +#!/bin/sh +## SPDX-FileCopyrightText: 2022 M. Shulhan <ms@kilabit.info> +## SPDX-License-Identifier: GPL-3.0-or-later + +## Script to recursively scan directory and remove executable-bit from file +## that may not an executable. +## +## Usage +## +## $ chmod-x.sh dir + +DIR=$1 + +if [[ -z "$DIR" ]]; then + echo "$0 <directory>" + exit 1 +fi + +IFS=: +MAYBE_BIN="ELF 32-bit | shell script | executable"; + +echo "Checking in directory: $DIR" + +for file in $(find $DIR -type f -perm /111 -printf "%p$IFS") +do + if ! file $file | grep -q -E "$MAYBE_BIN"; then + echo "$file" + chmod -x $file + fi +done |
