gzip
Extract .tar.gz file:
1
$ tar xvzf ./file.tar.gzExtract only one subdirectory and all its sub-content:
1
$ tar -xvzf my-archive.tar.gz --wildcards "./directory/subdirectory*"Create a .tar.gz file:
1
$ tar cvzf file.tar.gz ./subfolderExtract all .gz files in the current folder:
1
$ gunzip ./*.gzConvert .tar.gz file to .tar.bz2 file:
1
$ gzip -dc archive.tar.gz | bzip2 > archive.tar.bz2
bzip2
Extract .tar.bz2 file:
1
$ tar xvjf ./file.tar.bz2Check a .bz2 file integrity:
1
$ bzip2 --test ./file.bz2Extract ./path/in/archive* subfolder content from all .tar.bz2 archives available in the current folder. Place the extracted content of each archive in a folder prefixed with the content- string:
1
$ for ARCHIVE in `ls *.tar.bz2`; do DEST_FOLDER=content-`echo $ARCHIVE | cut -d '.' -f 1`; mkdir $DEST_FOLDER; tar -C $DEST_FOLDER -xvjf $ARCHIVE --wildcards "./path/in/archive*"; done
ZIP
Create a .zip archive of current directory, including all sub-dirs:
1
$ zip -r archive.zip ./*One liner to download an archive and extract its content to a target folder:
1
$ wget -O - "https://example.net/archive.zip" | tar -xz --directory /target-folder -f -
7-Zip
Create a 7-Zip archive (thanks to p7zip) of a folder, including all sub-directories:
1
$ 7za a archive.7z ./folderDo the same as above, but split the archive in 50 Mib volumes:
1
$ 7za a -v50m archive.7z ./folder