I have been trying to figure this out for hours and it just keeps giving me problems. I'm trying to pass 2 delimiter-containing strings as paramters to a bash script, iterate through them and echo the corresponding value 1,2,3 etc from array 1 in array 2's iteration
#!/bin/sh
export IFS='@@'
ThumbFilenames=$1
counterFiles=1
for thumbFilename in $ThumbFilenames; do
thumbFile[${counterFiles}]="${thumbFilename}"
counterFiles=$((counterFiles+1))
done
ThumbsIn=$2
counterThumbs=1
for thumbnumber in $ThumbsIn; do
echo "${thumbFile[${counterThumbs}]}"
echo "\n"
counterThumbs=$((counterThumbs+1))
done
however, running
./script.sh file1@@file2@@file3@@file4 thumb1@@thumb2@@thumb3@@thumb4
it just gives me this output
./script.sh: 9: thumbFile[1]=file1: not found
./script.sh: 9: thumbFile[2]=: not found
./script.sh: 9: thumbFile[3]=file2: not found
./script.sh: 9: thumbFile[4]=: not found
./script.sh: 9: thumbFile[5]=file3: not found
./script.sh: 9: thumbFile[6]=: not found
./script.sh: 9: thumbFile[7]=file4: not found
the output i need is
file1
file2
file3
file4