Difference between revisions of "Tar"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
To create an archive target.tar consisting of the folder /home, use:
 
To create an archive target.tar consisting of the folder /home, use:
 
  tar cvf target.tar /home
 
  tar cvf target.tar /home
 +
 +
= unpack an archive =
 +
To unpack an archive file, use
 +
tar xvf target.tar
  
 
= transmit a folder =
 
= transmit a folder =
Line 9: Line 13:
 
  tar cf - <dir> | ssh <user>@<host> tar -xvf  - -C <dir>
 
  tar cf - <dir> | ssh <user>@<host> tar -xvf  - -C <dir>
  
= unpack an archive =
+
= exclude files =
To unpack an archive file, use
+
  tar cvfz ''filename''.tar.gz -X excludefile
  tar xvf target.tar
+
In excludefile:
 +
/folder/subfolder
 +
 
 +
;IMPORTANT: There must not be a slash behind a folder name in the exclude file

Latest revision as of 09:39, 28 February 2010

tar is a command to pack files into an archive of the tar format. You can also use it to extract tar archive files.

pack an archive

To create an archive target.tar consisting of the folder /home, use:

tar cvf target.tar /home

unpack an archive

To unpack an archive file, use

tar xvf target.tar

transmit a folder

Thanks to the piping mechanism of Unix, you can also use tar to transmit a folder to another computer:

tar cf - <dir> | ssh <user>@<host> tar -xvf  - -C <dir>

exclude files

tar cvfz filename.tar.gz -X excludefile

In excludefile:

/folder/subfolder
IMPORTANT
There must not be a slash behind a folder name in the exclude file