I am trying to query a kubernetes Postgres pod using a bash script where i want to allow user to enter a variable and then use that variable to query. My bash script is as follows:
#!/bin/bash
echo "give a last name"
read t
kubectl exec -it postgres-pod -- bash -c "psql -U postgres -c 'Select * from users WHERE last_name=\"$t\"'"
I have tried all combinations of single and double quotes but i am unable to pass a string type username. Any suggestions would be appreciated
bash -c "psql -U postgres -c \"Select * from users WHERE last_name='$t';\""