|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
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> |
|
![]() |
| Outils de la discussion | |
|
|