Why does:
if [ "$(gpioget --chip 0 31)" == '"31"=active' ] ; then echo execute some commands fi
not work for you?