Skip to content

Instantly share code, notes, and snippets.

@izmailoff
Created December 27, 2019 09:38
Show Gist options
  • Save izmailoff/a40ae26837e279fb1f157928f1b36afa to your computer and use it in GitHub Desktop.
Save izmailoff/a40ae26837e279fb1f157928f1b36afa to your computer and use it in GitHub Desktop.
Grab all table columns only without any additional information from postgres. Ugly but works for me.
#!/bin/bash
for t in $(echo '\dt' | psql "$1" | cut -d '|' -f 2 | egrep -v 'List|Name|--|\(')
do echo "TABLE: $t"
echo "\d $t" | psql "$1" | grep '|' | egrep -v Column | cut -d '|' -f 1
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment