Working with tar


file-roller

If you’ve never worked with tar before or if you know few options this post will show how to use tar, at least the basic options. First of all, let’s see an extract from tar’s manual description:

“Tar stores and extracts files from a tape or disk archive. The first argument should be a function; either one of the letters Acdrtux, or one of the long function names.. A function letter need not be prefixed with ‘-’, and may be combined with other single-letter options. Some options take a parameter; with the single-letter form these must be given as separate arguments. A long function name must be prefixed with –”

Ok, let’s see some of those functions and options…

Tar’s functions and options

Function / Option Description
-f
It’s a file
-A
Append tar files to an archive
-c
Create a new archive
-d
Find differences between archive and file system
-r
Append files to the end of an archive
-t
List the contents of an archive
-z
Filter the archive through gzip
-j
Filter the archive through bzip2
-x
Extract files from an archive
--delete
Delete from the archive (not on mag tapes!)

Examples

Here’s some examples of how to use the tar command…

Creates a new archive from Images folder:

tar cfv images.tar Images/

Now let’ s read its content:

tar tf imagenes.tar

Ok, what about adding a new file:

tar rf images.tar Images/Screenshot.png

If you have a tar file and want to add it to another tar file type:

tar Af images.tar application.tar

Delete a file in the archive

tar f images.tar --delete Images/Screenshot.png

If you want to know changes in file system against archive:

tar df images.tar Images/

In order to create a tarball file made up of jpg files:

tar cfzv image.tar.gz Image/*.jpg

If you download Linux’s kernel from http://kernel.org, you’ll will need to extract it:

tar xfjv linux-2.6.30.tar.bz2

Reference

,

  1. #1 by Nelson Nieto on 28/06/2009 - 10:44 pm

    cambiale el titulo al articulo,
    que diga “Tareando”
    xD

(will not be published)