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 the directory and it'sits sub directory files in an array separately for each of /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 tocan I increase size of array dynamically.? set -A is not related to bash, but this dynamic increasing might be same for bash and ksh, Soso I have included it.
I have tried as below. to store in ana temporary file. as shown below:
printf "/usr\n`ls -lRt /usr|grep -v "total"|sed -e '1d' -e '/^$/d' -e '/^l/d'|awk '{print $1}'`\n" >> /tmp/output2.txt  # not working in ksh, but working when I run as bash
ksh: no space
ls -lRt /usr|grep -v "total"|sed -e '1d' -e '/^$/d' -e '/^l/d'|awk '{print $1}' >> /tmp/output2.txt # it is working
Why did the first command why it ranrun successfully in bash, why not but in ksh ?