Compressing Files

tar

tar -[crtx][vf]* <archive-file> [<file>*]

c :  Create
r : Append
t :  List
x :  Extract

v : Verbose
f : Use the specified archive file
  • Combine a number of files into a single file
  • Removes the leading "/" from any absolute paths
Create
tar -cvf archive.tar <files>

# Use the find command
find -type f -name '*.txt' | xargs tar -cvf archive.tar

# gzip compression
tar -zcvf archive.tgz <files>
Append
tar -rvf archive.tar <files>

# gzip compression
tar -zrvf archive.tgz <files>
List
tar -tvf archive.tar

# gzip compression
tar -ztvf archive.tgz
Extract
tar -xvf archive.tar

# gzip compression
tar -zxvf archive.tgz

zip

zip data.zip <files>
zip -r data.zip <dir>
Options
-u   update (only changed or new files)
-f freshen (only changed files)
-d delete entries in zipfile
-r recurse into directories