Datenkralle
Datenkralle

Reputation: 45

Bypass "-" processing as arithmetic operator in bash

#!/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 treats the "-" in rw- and rw-- as arithmetic operators but what I wanto to achieve is processing it as string because I want to work with output I get from getfacl $i |grep owner which gives me back a string I wanna echo in

echo ’BUERO\ $owner -user -group -type windows permission $permission

thanks in advance!

Upvotes: 0

Views: 126

Answers (1)

nos
nos

Reputation: 229184

Use if [[ $ownerPermission == "rwx" ]] and if [[ $ownerPermission == "rw-" ]]

The (( expr )) is used for arithemtic expressions, which you don't need here.

Upvotes: 3

Related Questions