I need to check the file permissions of directories /usr, /tmp, /var and their contents of sub directories. I have taken the file permissions of directory and it's sub directory files in array separately for /usr, /tmp, and /var. As below.
fun() {
set -A PR_Uperm -- "/usr" `ls -lRt /bin|grep -v "total"|sed -e '1d' -e '/^$/d' -e '/^l/d'|awk '{print $1}'`
set -A PR_Tperm -- "/tmp" `ls -lRt /bin|grep -v "total"|sed -e '1d' -e '/^$/d' -e '/^l/d'|awk '{print $1}'`
fun2
}
Finally I want these separate arrays to be in single array which is in a different function, as we have dynamic scope in scripts. I have tried as below:
fun2(){
set -A perm ${PR_Uperm[@]} ${PR_Tperm[@]}
}
when I execute the script I am getting this error.
script.sh:79919: subscript out of range
when I give only one array to perm array as below,I am getting no error.
set -A perm ${PR_Tperm[@]}
I have so many entries to store in perm array. How to increase size of array dynamically. set -A is not related to bash, but this dynamic increasing might be same for bash and ksh, So I have included.