1825793 Members
2443 Online
109687 Solutions
New Discussion

tar command ...

 
SOLVED
Go to solution
Manuales
Super Advisor

tar command ...

How can i use tar command in hp-ux B.11.11?

Thanks, Manuales.
8 REPLIES 8
Andrew Rutter
Honored Contributor
Solution

Re: tar command ...

hi,

in what way use tar command?

same as in other version of HPUX really, but depends what you want to do with tar.

check man entries for more info
#man tar

Andy



TwoProc
Honored Contributor

Re: tar command ...

well the simple way to create a tar file from the current directory of stuff you're currently sitting in...

cd /mysourcedir
tar cvf .tar .

where is the name of the tar file you wish to create, or the name of the tape drive you're trying to hit (e.g. /dev/rmt/0m).

so
cd /mysourcedir
tar cvf mysourcedir.tar .
or simply
tar cvf mysourcedir.tar /mysourcedir

would create a tar file of the contents of /mysourcedir. The first example buries the name of the directory as "." and the second buries the name of the directory as "/mysourcedir". This makes a difference when you extract the data later on.

To extract the data:

cd /mydestdir
tar xvf .tar .

would put the contents of .tar in the current directory (/mydestdir).

If you used the second method (mentioned above) to create the tar file with the absolutepath /mysourcedir embedded in the tar file, then you don't have much choice but to extract the data into /mysourcedir as well.

tar xvf .tar

would create the directory "/mysourcedir", if it doesn't exist, and put the files from the tar file in the /mysourcedir directory.

There's more, but that's the main two commands for tar.

Of course,

"man tar" for the rest.
We are the people our parents warned us about --Jimmy Buffett
A. Clay Stephenson
Acclaimed Contributor

Re: tar command ...

Essentially the same way you use tar on any other UNIX box. Man tar will tell you all you need to know.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: tar command ...

Hi Manuales:

# tar -cvf /tmp/archive /home

..would (c)reate a (f)ile named "/tmp/archive" for the contents of the '/home' directory and (v)erbosely record to your terminal the files archived.

# tar -xvf /tmp/archive

...would e(x)tract the archive (back into '/home' since we used absolute paths (not always a good thing!)

# tar -tvf /tmp/archive

...would merely list the contents of the archive.

With 'tar' archives (whether to a tape or to a file) it is ofter better to use relative paths. Thus in our first example:

# cd /home && tar -cvf /tmp/archive .

...would allow restoration later in a directory of our choice without a great deal of bother.

See the manpages for 'tar' and its cousin 'pax'.

Regards!

...JRF...


karan_3
Advisor

Re: tar command ...

Hi Manuales..
the use of tar command is same in all the flavour of unix...

tar is basically used for backup purpose.means you can take a backup of ur file by using tar..

# tar cvf < name of destination>

name of destination= /dev/rmt/0mn (device name of ur tape drive).

# tar cvf /dev/rmt/0mn /home
it will take a backup of ur home directory...

and you can view

# tar tvf /dev/rmt/0mn

and you can extract the backup

# tar xvf /dev/rmt/0mn

you can also make a archive file by using tar

tar cvf home.tar /home

i think this will solve youe doubt. see man page also..

regards
karan
Indrajit_1
Valued Contributor

Re: tar command ...

Hi;

To create a directory (dir1) to tar file

#tar -cvf dir1.tar /dir1

To untar a tar file.
#tar xvf dir1.tar

To untar a dir1.tar.z file

#tar -zxvf dir1.tar.z

Cheers
Indrajit
Never Ever Give Up
Manuales
Super Advisor

Re: tar command ...

Really, really thanks all !!!!
Adisuria Wangsadinata_1
Honored Contributor

Re: tar command ...

Hi Manuales,

Check the url (docID : KBAN00000907) about 'Example backup/recover commands for fbackup, cpio, tar' :

http://www2.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000076534352

Hope this information can help.

Cheers,
AW
now working, next not working ... that's unix