Last active
March 24, 2020 19:29
-
-
Save atgmello/26409a8ad8399fb39611d2b26a81ae3b to your computer and use it in GitHub Desktop.
DS4A Latam 2020 - Week 3 - Extended Case Automation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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