Skip to content

Instantly share code, notes, and snippets.

@YanhaoYang
Last active May 25, 2019 08:29
Show Gist options
  • Save YanhaoYang/bbb03b60f31b270c38f39283e30d3a6b to your computer and use it in GitHub Desktop.
Save YanhaoYang/bbb03b60f31b270c38f39283e30d3a6b to your computer and use it in GitHub Desktop.
Some notes for command lines
# Find all .orig files, and delete them with confirmation
find . -name "*.orig" && read -q "REPLY?Delete all?" && find . -name "*.orig" -delete && echo "\nDone."
# pg_restore with bandwidth control and progress bar
cat db.dump | pv -pera -s $(stat -c %s db.dump) -L 2000000 | pg_restore -d postgres://postgres:a@localhost/db_name --clean --no-owner --verbose -Fc
# check pg readiness
for i in {1..60}; do echo "Waiting for pg ..."; pg_isready -d $PG_URL && break || sleep 1; done
# http://www.grymoire.com/Unix/Awk.html
# https://www.gnu.org/software/gawk/manual/gawk.html#String-Functions
awk '{ x=gensub(/fwd="(.+)"/, "\\1", "g", $16); split(x, a, ","); print a[1]}' h12.log | uniq | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment