I am trying to run the code below however I am getting a "syntax error near unexpected token `for file in error" on the line that is in red. I have the semicolons after every line because it will fail on the copy if I don't have them saying that it cannot stat directory. Is there something that I am missing that would cause it to give me this error? I would really appreciate any advice or improvements.
#!/bin/bash -x
original=ALPHA.jan.R120110117.142731.txt;
origcp=$original.original;
location=/home/testfiles/;
rec=1000001;
DT=20110117;
TM=120000;
prefix=ALPHA.jan;
cp $location$original $location$origcp;
wc -l $location$original;
wc -l $location$origcp;
split -l $rec -a 3 $location$original $location$original;
chmod 775 $location$original???
for file in $location$original???
do
wc -l $location$original???
break
done;
ini=161;
i=161;
for file in $location$original???;
do
output=$(printf '%X' $i)$DT.$TM.txt;
mv $file $prefix.$output
i=$((i + 1 + 7*($i-$ini==8)))
ini=$((ini + 16*($i-$ini>8)))
print $file has been renamed to $prefix.$output
done;