bash/every-chmod: generate every combination of rwx for chmod

This commit is contained in:
Nick Chambers 2021-07-25 21:24:33 -05:00
parent e056f1eaf5
commit 6d18c17400
1 changed files with 24 additions and 0 deletions

24
bash/every-chmod Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
perms=(___ __x _w_ _wx r__ r_x rw_ rwx)
perms() {
local perm perm_str
for perm do
perm_str=$perm_str${perms[$perm]}
done
printf %s "$perm_str"
}
for owner in {0..7}; do
for group in {0..7}; do
for universe in {0..7}; do
printf 'chmod_%s() {\n' "$(perms "$owner" "$group" "$universe")"
printf ' chmod %d%d%d "$@"\n' "$owner" "$group" "$universe"
printf '}\n'
printf '\n'
done
done
done