It's not clear that what exactly you want to do. If you want to create a shell script then do as follow:
Note: Do not use $
symbol before variable name while you're declaring it, but use $
before it when you're either printing it or using it in script:
$variable_name=$(command) ## This is incorrect to use $ before variable name
variable_name=$(command) ## This is the correct way
Also once add debug mode i.e. set -xv
just below the #!/bin/bash
in your script and invoke the script again, so you can see where your script gets stuck.
Please use [code][code] around the command's output, that you're sharing, for ease of reading.