Reese Knowledgebase

Various tar/gzip one liners

View Kristian Reese's profile on LinkedIn

If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 44
by: Reese K.
Posted: 17 Jul, 2012
Last updated: 21 Feb, 2013
Views: 2877

Here, we are sending the tar file to ``-'', which stands for tar's standard output. This is piped to gzip, which compresses the incoming tar file, and the result is saved in backup.tar.gz. The -c option to gzip tells gzip to send its output to stdout, which is redirected to backup.tar.gz.

# tar cvf - /etc | gzip -9c > backup.tar.gz

A single command used to unpack this archive would be:

# gunzip -c backup.tar.gz tar xvf -


gunzip -c LDAPsetup.1.0.SPARC.SOL9.pkg.tar.gz | tar -xvf -

Create a tar file from list of files inside a text file

tar cfvz forhans.tar.gz `cat manifest.txt`

if there are spaces in the file, you will have issues

Backup home directory

(cd /home/reese; tar cf - *) > reese-hostname.tar

This article was:   Helpful | Not Helpful
Also listed in
folder UNIX -> Linux
folder UNIX -> Solaris
folder UNIX -> Scripting

Prev   Next
Setting file formats in VIM     How to decode a base64 string