Skip to content

Instantly share code, notes, and snippets.

@zhanglongqi
Forked from fabiomontefuscolo/xz.markdown
Created February 18, 2021 09:23
Show Gist options
  • Save zhanglongqi/96da93b14df383c7d96ab0f38e2ead10 to your computer and use it in GitHub Desktop.
Save zhanglongqi/96da93b14df383c7d96ab0f38e2ead10 to your computer and use it in GitHub Desktop.
XZ and tricks

XZ

  1. Compress a file (filename.sql will be replaced by filename.sql.xz)
xz filename.sql
  1. Uncompress file (filename.sql.xz will be replaced by filename.sql)
xz -d filename.sql.xz
  1. Compress folder
tar -cJvf folder.tar.xz folder/
  1. Uncompress folder
tar -xJvf folder.tar.xz folder/
  1. Compress file from stdin
mysqldump mydatabase | xz > mydump.sql.xz
  1. Uncompress and send content to stdout
xzcat mydump.sql.xz | mysql mydatabase
  1. Uncompress tar folder from stdin sent from ncat
ncat -l -p 7000 | tar -xJvf -
  1. Compress folder to stdout and send to ncat
tar -cJvz - folder/ | ncat targetserver.com 7000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment