jamesisin

December 21st, 2010, 03:17 AM

I am building a script to change time stamps in cue files. I have managed to parse out the bit I need to convert from frames (ff) to milliseconds (nnn), but when I run the array element through the arithmetic function in bash I get an error.

Here is the section of script in question:

for (( i=0 ; i < ${#cuefind[@]} ; i++ )) ; do

# path is cue iteration less file name

cuefolder="${cuefind[i]%/*.*}"

cat "${cuefind[i]}" | grep INDEX | awk -F':' '{print $3}' > /tmp/whyme2

declare -a ff

let ii=0

while read ffline; do

ff[$i]=$ffline

echo "ffline is " $ffline

nnn=$(( ( ffline * 1000 ) / 75 ))

echo "nnn is " $nnn

((ii++))

done < /tmp/whyme2

done

And here is the error I receive:

ffline is 00

")syntax error: invalid arithmetic operator (error token is "

Here is the script running without the variable in the equation (I just stuck in the real number 8 ) :

ffline is 00

nnn is 106

ffline is 38

nnn is 106

ffline is 38

nnn is 106

ffline is 56

nnn is 106

ffline is 38

nnn is 106

ffline is 38

nnn is 106

ffline is 28

nnn is 106

ffline is 38

nnn is 106

ffline is 19

nnn is 106

ffline is 13

nnn is 106

ffline is 19

nnn is 106

ffline is 19

nnn is 106

ffline is 66

nnn is 106

ffline is 00

nnn is 106

ffline is 38

nnn is 106

ffline is 38

nnn is 106

ffline is 56

nnn is 106

ffline is 00

nnn is 106

ffline is 38

nnn is 106

Clearly the problem is in the array somehow. I don't have the variable quoted which I think is fine because each element is just a two digit number, so I'm confused where the equation is bumping into a quotation mark.

A little help?

Here is the section of script in question:

for (( i=0 ; i < ${#cuefind[@]} ; i++ )) ; do

# path is cue iteration less file name

cuefolder="${cuefind[i]%/*.*}"

cat "${cuefind[i]}" | grep INDEX | awk -F':' '{print $3}' > /tmp/whyme2

declare -a ff

let ii=0

while read ffline; do

ff[$i]=$ffline

echo "ffline is " $ffline

nnn=$(( ( ffline * 1000 ) / 75 ))

echo "nnn is " $nnn

((ii++))

done < /tmp/whyme2

done

And here is the error I receive:

ffline is 00

")syntax error: invalid arithmetic operator (error token is "

Here is the script running without the variable in the equation (I just stuck in the real number 8 ) :

ffline is 00

nnn is 106

ffline is 38

nnn is 106

ffline is 38

nnn is 106

ffline is 56

nnn is 106

ffline is 38

nnn is 106

ffline is 38

nnn is 106

ffline is 28

nnn is 106

ffline is 38

nnn is 106

ffline is 19

nnn is 106

ffline is 13

nnn is 106

ffline is 19

nnn is 106

ffline is 19

nnn is 106

ffline is 66

nnn is 106

ffline is 00

nnn is 106

ffline is 38

nnn is 106

ffline is 38

nnn is 106

ffline is 56

nnn is 106

ffline is 00

nnn is 106

ffline is 38

nnn is 106

Clearly the problem is in the array somehow. I don't have the variable quoted which I think is fine because each element is just a two digit number, so I'm confused where the equation is bumping into a quotation mark.

A little help?