updated code: please review- the below code replace the assignment of MD5 with the actual password hash.
# Update password
shadow=$(grep ^$user: /etc/shadow)
shdw3=$(echo "$shadow" | cut -f3 -d

shdw4=$(echo "$shadow" | cut -f4 -d

shdw5=$(echo "$shadow" | cut -f5 -d

shdw6=$(echo "$shadow" | cut -f6 -d

shdw7=$(echo "$shadow" | cut -f7 -d

shdw8=$(echo "$shadow" | cut -f8 -d

shdw9=$(echo "$shadow" | cut -f9 -d

shadow_str="$user:$shdw2:$shdw3:$shdw4:$shdw5:$shdw6"
shadow_str="$shadow_str:$shdw7:$shdw8:$shdw9"