The remote invocation will not work since you're pasting bash script into the prompt of redis-cli.
Also, try to use this on the conditional expressions: [[ $TTL -eq -1 ]]
[[ $TTL -eq -1 ]]
(two brackets instead).