Bash - Tar


Archiving command. Can be used with gzip to make a tar ball (.tar.gz).

Compress

$ tar -czvf compress.tar.gz /path/to/compress
  • -c: Create a new archive (group files together, the .tar part)
  • -z: Filter archive through gzip (compress, the .gz part)
  • -v: Verbose, list files processed (can get annoying)
  • -f: Name to save archive as

Remove files while being archived:

tar -czf compressed.tar.gz --remove-files path/to/compress

Uncompress

$ tar -xzvf compress.tar.gz
  • -x: Extract files from an archive (Undoes the .tar part)
  • -z: Filter archive through gzip (uncompress, the .gz part)
  • -v: Verbose, list files processed (can get annoying)
  • -f: Name of archive file to use