, , , :
stat --format '%A' myFile | sed -E -e 's/(...)(...)(...)$/u=\1,g=\2,o=\3/;s/(s|t)/x\1/g;s/(S|T)/\l\1/g;s/-//g;s/(u|g)=,/\1-rwxs,/g;s/o=$/o-rwxt/g'
, bash, (8 * 8 * 8 * 8 = 4096 !)
test_file=/tmp/a
return_code=0
echo -e "from itertools import product;\nfor mod in product('01234567', repeat=4) : print ''.join(mod)" | python | shuf |
while read octalMod
do
chmod $octalMod $test_file
symbolicMod=$(stat --format '%A' $test_file | sed -E -e 's/(...)(...)(...)$/u=\1,g=\2,o=\3/;s/(s|t)/x\1/g;s/(S|T)/\l\1/g;s/-//g;s/(u|g)=,/\1-rwxs,/g;s/o=$/o-rwxt/g')
chmod 0000 $test_file
chmod $symbolicMod $test_file
modActual=$(stat --format '%a' $test_file)
if [ $octalMod -ne $modActual ]
then
echo "$octalMod ($symbolicMod) !!! octalMod=$octalMod <> modActual=$modActual" >&2
return_code=255
else
echo "$octalMod ($symbolicMod) octalMod=$octalMod == modActual=$modActual" >&1
fi
done
exit $return_code
:
test_file=/tmp/a
echo -e "octalMod\thumanMod\tsymbolicMod"
echo -e "from itertools import product;\nfor mod in product('01234567', repeat=4) : print ''.join(mod)" | python |
while read octalMod
do
chmod $octalMod $test_file
symbolicMod=$(stat --format '%A' $test_file | sed -E -e 's/(...)(...)(...)$/u=\1,g=\2,o=\3/;s/(s|t)/x\1/g;s/(S|T)/\l\1/g;s/-//g;s/(u|g)=,/\1-rwxs,/g;s/o=$/o-rwxt/g')
humanMod=$(stat --format '%A' $test_file)
echo -e "$octalMod\t$humanMod\t$symbolicMod"
done
echo -e "octalMod\thumanMod\tsymbolicMod"
:
octalMod humanMod symbolicMod
0001 ---------x u-rwxs,g-rwxs,o=x
0354 --wxr-xr-- u=wx,g=rx,o=r
1210 --w---x--T u=w,g=x,o=t
3337 --wx-wsrwt u=wx,g=wxs,o=rwxt
3566 -r-xrwSrwT u=rx,g=rws,o=rwt
3734 -rwx-wsr-T u=rwx,g=wxs,o=rt
6734 -rws-wsr-- u=rwxs,g=wxs,o=r
7121 ---s-wS--t u=xs,g=ws,o=xt
7430 -r-S-ws--T u=rs,g=wxs,o=t
7611 -rwS--s--t u=rws,g=xs,o=xt