> $ TEST=16; psql -c "select $TEST as \"input1\";"> $ TEST=16; echo "select $TEST as \"input1\";" | psql
Yep that works. My coworker also suggested using <<EOF to simulate a psql script.