Unable to assign command output to variable

Code

set -x
STATUS="0"
echo $STATUS
for i in `ls -ltr Report*|awk '{ print $9 }'`
do
if [ "`fuser "$i" 2>/dev/null`" -eq "" ]
then
flg = "`head -1 "$i" |cut -c 31-33`"
echo `head -1 "$i" |cut -c 31-33`
echo $flg
if [ $flg = "FUN" ]
then
echo "having Fun"
STATUS="2"
else
echo "no Fun"
fi
fi
done

Output

+ STATUS=0
+ echo 0
0
+ ls -ltr Report123.dat
+ awk { print $9 }
+ fuser Report123.dat
+ 2> /dev/null
+ [  -eq  ]
+ head -1 Report123.dat
+ cut -c 31-33
+ flg = FUN
./ararm_856_checkfile.sh[8]: flg:  not found
+ head -1 Report123.dat
+ cut -c 31-33
+ echo FUN
FUN
+ echo
+ [ = FUN ]
./ararm_856_checkfile.sh[11]: test: argument expected
+ echo no Fun
no Fun

No whitespace when making assignments.

flg=something

is not the same as

flg = something

and there is no reason for `ls -ltr Report*|awk '{ print $9 }'` . in fact it'll break eventually. just use for i in Report*

Neutron and Sumtaru