tar

Create and extract tar archives

Usage

Extract archive

      tar -xf ARCHIVE
    

Extracts ARCHIVE

Create archive

      tar -cf ARCHIVE DIRECTORY
    

Archives DIRECTORY inside ARCHIVE

Common Flags

-x, --extract Extract files from an archive-c, --create Create a new archive-f, --file=ARCHIVE Specify the archive to create/extract-C, --directory=DIR Extract to DIR instead of the current working directory-v, --verbose List files processed-z, --gzip Create tar.gz archive-j, --bzip2 Create tar.bz2 archive

Examples

Extract archive

      tar -xvf nvim.tar.gz
    

Extracts nvim.tar.gz to the current directory

Extract to another directory

      tar -xvf android-studio.tar.gz -C /opt
    

Extracts android-studio.tar.gz to the /opt directory

Create archive

      tar -cf assignments.tar assignment1/
    

Archives assignment1/ inside assignment.tar

Archive multiple items

      tar -cf assignments.tar assignment1/ assignment2/
    

Archives the assignment1 and assignment2 directories

Create Gzip archive

      tar -czf assignments.tar.gz assignment1/
    

Archives assignment1/ using Gzip compression