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:
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.