有没有简单的方法来转换文件权限?
例如:
if [ filePermission = -rw-r--r-- ]
then
echo 644
fi
if [ filePermission = -r-xr-xr-x ]
then
echo 555
fi
# etc..
我不是要更改权限,只需查看八进制值。
像这样的东西:
-bash-4.1$ ls -l test*
-rw-r--r-- 1 user joe 0 Nov 11 09:41 test1
-r-xr-xr-x 1 user joe 0 Nov 11 10:12 test2*
-r--r----- 1 user joe 0 Nov 11 10:14 test3
-rwxr-x--- 1 user joe 0 Nov 11 10:17 test4*
-bash-4.1$ ./perm test*
test1:
permissions: 644
test2:
permissions: 555
test3:
permissions: 440
test4:
permissions: 750