Skip to content

Instantly share code, notes, and snippets.

@EduardoPazz
Forked from faesin/tarcheatsheet.md
Last active April 30, 2021 16:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EduardoPazz/bd4cca19494867b8088d9645e93c3427 to your computer and use it in GitHub Desktop.
Save EduardoPazz/bd4cca19494867b8088d9645e93c3427 to your computer and use it in GitHub Desktop.
Tar usage / Tar Cheat Sheet

Tar Usage / Cheat Sheet

Commands

Compress: tar -cv$f name-of-archive.tar.$$ /path/to/directory-or-file

Extract: tar -xv$f name-of-archive.tar.$$ /path/to/directory-or-file

  • c: Create an archive;
  • x: Extract from archive;
  • v: Allow verbose output;
  • f: Specify the filename of the archive. It must be the last option;
  • $: placeholder for some of the compression utilities:
  • $$: placeholder for the file extension of some of the compression utilities:

Excluding a directory from compression

e.g.: tar -cv$f name-of-archive.tar.$$ /path/to/dir-or-file --exclude=/path/to/dir-or-file/pattern1 --exclude=/path/to/dir-or-file/pattern2

Exclude takes a patern, not necessarily file names or paths. So doing something like --exclude=*.png, for instance, would exclude all png-type files to be compressed.

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