#!/bin/bash
dir=$1
cd $dir
list=$(find . -maxdepth 1 -mindepth 1 -type d -printf '%f,')
IFS=',' read -a array <<< "${list}"
for i in "${array[@]}"
do
longPermission=$(getfacl $i |stat -c %A $i)
longOwner=$(getfacl $i |grep owner)
ownerPermission=${longPermission:1:3}
owner=${longOwner:9}
if (($ownerPermission=="rwx"))
then
permission='FULL_PERMISSION'
fi
if (($ownerPermission=="rw-"))
then
permission='READ/WRITE_PERMISSION'
fi
#if (($ownerPermission=="r--"))
#then
# permission='READ_ONLY_PERMISSION'
#fi
echo ’BUERO\ $owner -user -group -type windows permission $permission’
done
Bash 将 rw- 和 rw-- 中的“-”视为算术运算符,但我想实现的是将其作为字符串处理,因为我想处理从 getfacl $i |grep owner 获得的输出,这会返回给我我想回显的字符串
echo 'BUERO\$owner -user -group -type windows permission $permission'
提前致谢!
最佳答案
使用 if [[ $ownerPermission == "rwx"]]
和 if [[ $ownerPermission == "rw-"]]
(( expr ))
用于算术表达式,此处不需要。
关于linux - 绕过 "-"在 bash 中作为算术运算符处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55062133/