Can't see an error in this snippet - there must be some error elsewhere in your script. Maybe add a set -x in the head of the script and post the output here.
check.sh: 9: arr[i++]=Resume_A_09_v2.pdf: not found
check.sh: 9: arr[i++]=SciTE.4115.in: not found
check.sh: 9: arr[i++]=kde-a: not found
check.sh: 9: arr[i++]=keyring-fghIJp: not found
check.sh: 9: arr[i++]=ksocket-a: not found
check.sh: 9: arr[i++]=orbit-a: not found
check.sh: 9: arr[i++]=orbit-root: not found
check.sh: 9: arr[i++]=plugtmp: not found
check.sh: 9: arr[i++]=pulse-dExDc8m05Dcj: not found
check.sh: 9: arr[i++]=seahorse-6OBRgA: not found
check.sh: 9: arr[i++]=ssh-zVGRKA3354: not found
check.sh: 9: arr[i++]=virtual-a.Zm5Csq: not found
check.sh: 11: Bad substitution
i copy exxactly the code you put i change the valor of $CPFs
for a directory of my server, and the script work OK (HP-UX, with sh)....
the error is in line 42 but the code you put si more short than 42 lines, can you put all the code of you scritp
when i write the my last time i don't see all you response but now i read...
I'm probing, now i'm in linux enviorement with bash and i has the same problem that you say.
$ sh new.sh
new.sh: 11: ARRs[0]=dir1: not found
new.sh: 11: ARRs[1]=dir2: not found
As i now in sh (i don't now version) you must declare as array de variable, for this porpuse is
man sh
" sh is the standard command interpreter for the system. The current ver
sion of sh is in the process of being changed to conform with the POSIX
1003.2 and 1003.2a specifications for the shell. This version has many
features which make it appear similar in some respects to the Korn shell,
but it is not a Korn shell clone (see ksh(1)). "
man ksh
" To assign values to an
array, use set -A name value .... The value of all subscripts must be
in the range of 0 through 1023. Arrays need not be declared. Any
"
if you execute ./new.sh you execute under bash because is your shell by defect...and shell works Ok, you can optain the same result if you execute:
bash new.sh
I'm think that when you execute whith sh something happens and the error is the same that if yo make this shell in old unix version ( o may be better said old sh ) that they need you declare de arrays with
set -a ARRs valor1 valor2 .......
i'm not suere what is the problem but think this thinks can be relation...
(sorry i'm spanish and i don't explain so good in english)