PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > tar problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

tar problem

Réponse
 
LinkBack Outils de la discussion
Vieux 29/07/2007, 14h22   #1
enjoyfate@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut tar problem

hi, guys
I have a tar file to extract .When I used " tar jxvf a.tar.bz2 "
command to extract , in current directory it makes mnt/c/....,
extarcted files all in that directory, but i do not want that
prefix ,so how to do that ?
Any is greatly appreciated! Thanks!

  Réponse avec citation
Vieux 29/07/2007, 14h58   #2
Franco
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

On Jul 29, 2:22 pm, enjoyf...@gmail.com wrote:
> hi, guys
> I have a tar file to extract .When I used " tar jxvf a.tar.bz2 "
> command to extract , in current directory it makes mnt/c/....,
> extarcted files all in that directory, but i do not want that
> prefix ,so how to do that ?
> Any is greatly appreciated! Thanks!


If you used the absoulte path to tar the files together then it will
create this path on extract.

Anyways, you have a .bz2 file so shouldn't you be doing bzip2 -d
a.tar.bz2, then using tar in your current directory.

tar xvf a.tar .

Im not familar with the "j" flag in tar, what is the purpose of this
flag ?

Franco.

  Réponse avec citation
Vieux 29/07/2007, 19h04   #3
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

On Sun, 29 Jul 2007 06:58:49 -0700, Franco
<franco_spencer@yahoo.com> wrote:
>
> Anyways, you have a .bz2 file so shouldn't you be doing bzip2 -d
> a.tar.bz2, then using tar in your current directory.
>
> tar xvf a.tar .
>
> Im not familar with the "j" flag in tar, what is the purpose of this
> flag ?
>

The j flag in GNU tar extracts or creates tar.bz2 files, like the z flag
does tar.z.

--
It is wrong always, everywhere and for everyone to believe anything upon
insufficient evidence.
-- W. K. Clifford, British philosopher, circa 1876
  Réponse avec citation
Vieux 29/07/2007, 19h24   #4
Franco
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

On Jul 29, 7:04 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On Sun, 29 Jul 2007 06:58:49 -0700, Franco <franco_spen...@yahoo.com> wrote:
>
> > Anyways, you have a .bz2 file so shouldn't you be doing bzip2 -d
> > a.tar.bz2, then using tar in your current directory.

>
> > tar xvf a.tar .

>
> > Im not familar with the "j" flag in tar, what is the purpose of this
> > flag ?

>
> The j flag in GNU tar extracts or creates tar.bz2 files, like the z flag
> does tar.z.
>
> --
> It is wrong always, everywhere and for everyone to believe anything upon
> insufficient evidence.
> -- W. K. Clifford, British philosopher, circa 1876


Cheers for that, never used GNU tar.

  Réponse avec citation
Vieux 29/07/2007, 19h59   #5
Kenan Kalajdzic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

enjoyfate@gmail.com wrote:
> hi, guys
> I have a tar file to extract .When I used " tar jxvf a.tar.bz2 "
> command to extract , in current directory it makes mnt/c/....,
> extarcted files all in that directory, but i do not want that
> prefix ,so how to do that ?
> Any is greatly appreciated! Thanks!


You probably created the archive using absolute pathnames, and as you
seem to be using the GNU tar, it stripped the leading slash leaving
you with mnt/c/ in front of every filename. You should generally avoid
creating archives using absolute pathnames except in special cases
where these should be retained (for instance, in some backup scripts).
In this particular case, you could first extract the archive into a
temporary directory, then move all the files to a desired destination:

$ mkdir /tmp/for_tar
$ cp /path/to/a.tar.bz2 /tmp/for_tar
$ cd /tmp/for_tar
$ bunzip2 a.tar.bz2
$ tar xf a.tar
$ mv mnt/c/* /your/destination/dir
$ cd /
$ rm -rf /tmp/for_tar

--
Kenan Kalajdzic
  Réponse avec citation
Vieux 29/07/2007, 19h59   #6
Kenan Kalajdzic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

enjoyfate@gmail.com wrote:
> hi, guys
> I have a tar file to extract .When I used " tar jxvf a.tar.bz2 "
> command to extract , in current directory it makes mnt/c/....,
> extarcted files all in that directory, but i do not want that
> prefix ,so how to do that ?
> Any is greatly appreciated! Thanks!


You probably created the archive using absolute pathnames, and as you
seem to be using the GNU tar, it stripped the leading slash leaving
you with mnt/c/ in front of every filename. You should generally avoid
creating archives using absolute pathnames except in special cases
where these should be retained (for instance, in some backup scripts).
In this particular case, you could first extract the archive into a
temporary directory, then move all the files to a desired destination:

$ mkdir /tmp/for_tar
$ cp /path/to/a.tar.bz2 /tmp/for_tar
$ cd /tmp/for_tar
$ bunzip2 a.tar.bz2
$ tar xf a.tar
$ mv mnt/c/* /your/destination/dir
$ cd /
$ rm -rf /tmp/for_tar

--
Kenan Kalajdzic
  Réponse avec citation
Vieux 29/07/2007, 20h31   #7
jellybean stonerfish
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

On Sun, 29 Jul 2007 11:24:36 -0700, Franco wrote:

> On Jul 29, 7:04 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:
>> On Sun, 29 Jul 2007 06:58:49 -0700, Franco <franco_spen...@yahoo.com> wrote:
>>
>> > Anyways, you have a .bz2 file so shouldn't you be doing bzip2 -d
>> > a.tar.bz2, then using tar in your current directory.

>>
>> > tar xvf a.tar .

>>
>> > Im not familar with the "j" flag in tar, what is the purpose of this
>> > flag ?

>>
>> The j flag in GNU tar extracts or creates tar.bz2 files, like the z flag
>> does tar.z.
>>
>> --
>> It is wrong always, everywhere and for everyone to believe anything upon
>> insufficient evidence.
>> -- W. K. Clifford, British philosopher, circa 1876

>
> Cheers for that, never used GNU tar.


It's gets even better. I just use tar -xf file.tar.bz and gnu tar knows
to bunzip2 it. Or gunzip it if that is the case. If the file has no .bz
it still knows and expands it.

stonerfish
  Réponse avec citation
Vieux 30/07/2007, 10h41   #8
Robert Bonomi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

In article <1185715323.560608.241230@i38g2000prf.googlegroups .com>,
<enjoyfate@gmail.com> wrote:
>hi, guys
> I have a tar file to extract .When I used " tar jxvf a.tar.bz2 "
>command to extract , in current directory it makes mnt/c/....,
>extarcted files all in that directory, but i do not want that
>prefix ,so how to do that ?
>Any is greatly appreciated! Thanks!
>


The 'right way' is to make the tarfile without the prefix.

There is no way to tell tar, on extract, to ignore the first part of the
paths as recorded in the tarfile

You have two choices --
The first is to extract 'as named', and then to do a recursive mv to put
things where you want them.

The second has risks and caveats. Do NOT use unless you understand
-exactly- what the effects of this 'dirty tricks' approach are.
Given:
1) you do not have a file or directory named 'mnt' in the directory you
want to extract to;
2) you do not have a file or directory named 'c' in the directory you
want to extract to;
3) there is no file or directory named 'mnt' in directory 'c' in the
tarfile
4) there is no file or directory named 'c' in directory 'c' in the
tarfile
*IF* all those conditions are met, then you can do the following
ln -s 1. mnt
ln -s . c
tar jxvf {file}
rm c
rm mnt
  Réponse avec citation
Vieux 30/07/2007, 11h00   #9
Teo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

On Jul 29, 3:22 pm, enjoyf...@gmail.com wrote:
> hi, guys
> I have a tar file to extract .When I used " tar jxvf a.tar.bz2 "
> command to extract , in current directory it makes mnt/c/....,
> extarcted files all in that directory, but i do not want that
> prefix ,so how to do that ?
> Any is greatly appreciated! Thanks!


Hi,

if you are using gnu tar:

--strip-components NUMBER, --strip-path NUMBER
strip NUMBER of leading components from file names
before extraction

(1) tar-1.14 uses --strip-path, tar-1.14.90+ uses --
strip-components
Matteo

  Réponse avec citation
Vieux 30/07/2007, 13h57   #10
Geoff Clare
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tar problem

enjoyfate wrote:

> I have a tar file to extract .When I used " tar jxvf a.tar.bz2 "
> command to extract , in current directory it makes mnt/c/....,
> extarcted files all in that directory, but i do not want that
> prefix ,so how to do that ?


bzcat a.tar.bz2 | pax -r -pp -s,mnt/c/,,

(pax is the standard POSIX utility for reading and writing tar and
cpio files).

If you are running as root and want to preserve ownership then use -pe
instead of -pp.

--
Geoff Clare <netnews@gclare.org.uk>
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h47.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14102 seconds with 18 queries