• Extract .tar.gz file:

    $ tar xvzf ./file.tar.gz
  • Extract only one subdirectory and all its sub-content:

    $ tar -xvzf my-archive.tar.gz --wildcards "./directory/subdirectory*"
  • Create a .tar.gz file:

    $ tar cvzf file.tar.gz ./subfolder
  • Extract ./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:

    $ 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
  • Extract all .gz files in the current folder:

    $ gunzip ./*.gz
  • Extract .tar.bz2 file:

    $ tar xvjf ./file.tar.bz2
  • Check a .bz2 file integrity:

    $ bzip2 --test ./file.bz2
  • Create a .zip archive of current directory, including all sub-dirs:

    $ zip -r archive.zip ./*
  • Create a 7-Zip archive (thanks to p7zip) of a folder, including all sub-directories:

    $ 7za a archive.7z ./folder
  • Do the same as above, but split the archive in 50 Mib volumes:

    $ 7za a -v50m archive.7z ./folder
  • Convert .tar.gz file to .tar.bz2 file:

    $ gzip -dc archive.tar.gz | bzip2 > archive.tar.bz2
  • Extract content from self-extracting shell archives:

    $ unshar archive.sh

Related content