Enclose command with $(...)
$(...)
z=$(wc -l temp.txt | cut -d " " -f1)
Since error is on line 5 so please change following in your script: