Skip to content

Instantly share code, notes, and snippets.

@atgmello
Last active March 24, 2020 19:29
Show Gist options
  • Save atgmello/26409a8ad8399fb39611d2b26a81ae3b to your computer and use it in GitHub Desktop.
Save atgmello/26409a8ad8399fb39611d2b26a81ae3b to your computer and use it in GitHub Desktop.
DS4A Latam 2020 - Week 3 - Extended Case Automation
#!/bin/sh
# Reads query from file
query=$(cat $1)
# Creates output file
touch $2
# Performs query
PGPASSWORD=[password] psql -h [server] -U postgres -d [database] -c "${query}" > $2
# Removes first line
echo "$(sed '1d' $2)\n" > $2
# Formats for Markdown
sed -i 's/\+/|/g' $2
# Copies to clipboard
xclip -sel c < $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment