Skip to content

Instantly share code, notes, and snippets.

@awesomebytes
Last active July 17, 2023 20:45
Show Gist options
  • Save awesomebytes/07753c3879afcbfd852ae2d0f5fe2952 to your computer and use it in GitHub Desktop.
Save awesomebytes/07753c3879afcbfd852ae2d0f5fe2952 to your computer and use it in GitHub Desktop.
Extract/Create compressed .tar.gz file directly on remote machine

Extract .tar.gz directly on remote machine

cat BIG_FILE.tar.gz | ssh user@192.168.1.12 "tar xzf - -C /home/user"

This magic command uses the network to only transfer the file and as it reaches the target computer it starts getting decompressed straightaway. Minimum traffic, no temporal disk usage.

Create .tar.gz directly on remote machine

tar czf - /home/user | ssh sam@192.168.1.15 "cat > /my/place/to/store/BIG_FILE.tar.gz"

This creates the compressed file on the fly and writes it in the remote machine without intermediate copies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment