- How to compress and uncompress files and folders in the Terminal
- Bluehost Compress/Decompress files via CLI
- Linux tar command
- How to Extract Tar Files to Specific or Different Directory in Linux
Flags create a new archive
-c, --create
verbosely list files processed
-v, --verbose
filter the archive through gzip
-z, --gzip
use archive file or device ARCHIVE
-f, --file=ARCHIVE
extract files from an archive
-x, --extract, --get
delete from the archive (not on mag tapes!)
--delete
# Tar files & folders
$ tar -cvzf NAME.tar.gz file1.ext file2.ext directory/
# Exclude Files & Folders
$ tar -czvf folder/NAME.tar.gz --exclude 'file/to/exclude.txt' --exclude 'folder/to-exclude' folder/to/tar
# Extract in current directory
$ tar -xvzf archive.tar.gz
# Extract in specified directory
$ tar -zxvf path/file.tar.gz -C /path/to/directory
# Choose directory name during untarring and remove first folder
$ tar -xvzf sql-dump/dev.tar.gz -C public_html/dev --strip-components 1