diff options
| author | Shulhan <ms@kilabit.info> | 2022-09-17 17:58:27 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-09-17 22:28:30 +0700 |
| commit | 36bc0c7fb5df2b9dfebb9be153ccdea46c0b3d80 (patch) | |
| tree | a5b80c2d495c14804aba434ce81c4f14eea225ce /bin | |
| parent | 397789cea60237f357476c86df96cd234e7b37eb (diff) | |
| download | bin.sh-36bc0c7fb5df2b9dfebb9be153ccdea46c0b3d80.tar.xz | |
all: add script chmod-x.sh
chmod-x.sh is a script to remove executable bit from file that may not
an executable.
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 |
