3

I'm looking to create a script than can find a specific date/time based on a field in a database Currently i do it manually...

# psql gttvdb -U postgres
gttvdb=# select patch_date from version_history where version ='1.1.1';

What i need is to be able to reference that date as a variable in a bash script

#! /bin/sh
patchdate=$("select patch_date from version_history where version ='1.1.1';")
echo "last update was " $patchdate

1 Answer 1

3

Try this:

patchdate=` psql -t -q -c "select patch_date from version_history where version ='1.1.1'"`
Sign up to request clarification or add additional context in comments.

1 Comment

read dtin patchdate=psql gttvdb -U postgres -t -q -c "select patch_date from version_history where version = '$dtin' ORDER BY ID DESC limit 1;"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.