unset -f o2s
function o2s () { touch ~/.octal2symbolic; chmod -vv "$@" "$_"; ls -l "$_" | awk '{print $1}'; rm -f ~/.octal2symbolic; }
o2s 755
o2s 644
o2s 1744
o2s 0100751
o2s 0101751
UMASKO=$(umask)
help umask
umask
umask -p
umask -S
umask 0077
umask
umask -S
o2s 755
umask 0000
umask
umask -S
o2s 654
umask $UMASKO
unset -f s2o
function s2o () {
OPATH=$PATH; OIFS=$IFS
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export IFS=$' \t\n'
unset -v FILE logname num str
declare FILE="${HOME}/.symbolic2octal" logname="$(/usr/bin/logname)" str="chmod ${@} file.txt"
declare num=$((${#str} + 5)) # calculate string length for dynamic printf spacing
touch "${FILE}"
chown "${logname}":"${logname}" "${FILE}"
printf "%-${num}s %s\n" "${str}" "file permission command"
chmod 000 "${FILE}"
if [[ "${@}" != "${@/-/}" ]]; then # if the string contains a minus sign ...
chmod 777 "${FILE}"
printf "\e[32m%-${num}s\e[m %s\n" "100777" "initial file permissions"
else
printf "\e[32m%-${num}s\e[m %s\n" "100000" "initial file permissions"
fi
chmod "$@" "${FILE}"
printf "\e[1m%-${num}s\e[m %s\n" "$(stat -f %p "${FILE}")" "resulting file permissions"
#stat -f %Sp "${FILE}"
/bin/rm -f ~/.symbolic2octal
export PATH=$OPATH; export IFS=$OIFS
return 0
}
s2o a-w
s2o a+w
s2o u=rwx,g=rx,o=x
s2o u=rwx,g-x,o=x
s2o u=rx,g-x,o=x
s2o u=rx,g+x,o=x
s2o u=rwx,g=rx,o=x,+t
unset -f s2o
function s2o () {
OPATH=$PATH; OIFS=$IFS
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export IFS=$' \t\n'
unset -v FILE logname num str
declare FILE="${HOME}/.symbolic2octal" logname="$(/usr/bin/logname)" str="chmod ${@} file.txt"
declare num=30
touch "${FILE}"
chown "${logname}":"${logname}" "${FILE}"
printf "%-${num}s %s\n" "file permission command:" "${str}"
chmod 000 "${FILE}"
if [[ "${@}" != "${@/-/}" ]]; then # if the string contains a minus sign ...
chmod 777 "${FILE}"
printf "%-${num}s \e[32m%s\e[m\n" "initial file permissions:" "100777"
else
printf "%-${num}s \e[32m%s\e[m\n" "initial file permissions:" "100000"
fi
chmod "$@" "${FILE}"
printf "%-${num}s \e[1m%s\e[m\n" "resulting file permissions:" "$(stat -f %p "${FILE}")"
#stat -f %Sp "${FILE}"
/bin/rm -f ~/.symbolic2octal
export PATH=$OPATH; export IFS=$OIFS
return 0
}
s2o a-w
s2o a+w
s2o u=rwx,g=rx,o=x
s2o u=rwx,g-x,o=x
s2o u=rx,g-x,o=x
s2o u=rx,g+x,o=x
s2o u=rwx,g=rx,o=x,+t