Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Bash script to check permission and store it

function permchk (){

        if [ -z "$1" ]; then
        echo "Enter path: ./test path"
else
        namecal="$(basename ${1}).$(date +%F).$$"
        touch ~/$namecal
        truncate -s 0 ~/$namecal
        result=$(sudo ls -ld ${1} >> ~/$namecal)
fi
}

permchk $1

if [[ $? -eq 0 && ! -z permchk ]]; then
        echo "permission check completed."
        vim ~/$namecal
fi
 
PREVIOUS NEXT
Tagged: #Bash #script #check #permission #store
ADD COMMENT
Topic
Name
4+3 =