Skip to main content
Grammar
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

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 ?

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.

I have tried as below. to store in an temporary file.

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

first command why it ran successfully in bash, why not in ksh ?

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 its sub directory files in an array separately for each of /usr, /tmp, and /var:

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 can I 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 it.

I have tried to store in a 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 run successfully in bash but in ksh ?

added 327 characters in body
Source Link
Sriram P
  • 153
  • 1
  • 6

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.

I have tried as below. to store in an temporary file.

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

first command why it ran successfully in bash, why not in ksh ?

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.

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.

I have tried as below. to store in an temporary file.

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

first command why it ran successfully in bash, why not in ksh ?

edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
Minor formatting
Source Link
Stephen Rauch
  • 4.3k
  • 15
  • 24
  • 33
Loading
Source Link
Sriram P
  • 153
  • 1
  • 6
Loading