[opensuse] Does tar descend into directories before extract?
Hello Everyone, I am untarring an archive but I like tar to descend one level into the directory within the archive and extract the file/folder therein, I had assumed '--level' would do the job but it looks like I am mistaken, does anyone know if tar support this feature? - Regards -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
General Mail wrote:
Hello Everyone,
I am untarring an archive but I like tar to descend one level into the directory within the archive and extract the file/folder therein, I had assumed '--level' would do the job but it looks like I am mistaken, does anyone know if tar support this feature?
- Regards
Hi General I guess you've already tried "man tar" ? If you want to extract specific files or directories from an archive, you just list them on the command line. -- Per Jessen, Zürich (-1.1°C) http://www.dns24.ch/ - free DNS hosting, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 01/24/2013 05:29 AM, General Mail wrote:
Hello Everyone,
I am untarring an archive but I like tar to descend one level into the directory within the archive and extract the file/folder therein, I had assumed '--level' would do the job but it looks like I am mistaken, does anyone know if tar support this feature?
please mention the operating system and version, as well as the version of tar that you are using.. and copy/paste back to this thread the exact tar command which is not giving you what you expect (and you might explain what you expect: for example, you say you expect it to extract from _the_ directory within, but if "the directory within contains several directories, do you want it to unpack each or just show you that there are directories below "the directory within"....or are you wanting to completely unpack every file in every directory in the archive?) dd -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 01/24/2013 05:29 AM, General Mail wrote:
I am untarring an archive but I like tar to descend one level into the directory within the archive and extract the file/folder therein, I had assumed '--level' would do the job but it looks like I am mistaken, does anyone know if tar support this feature?
Hi General, ;-) I don't know if I understood correctly what you want - as you didn't give a concrete example - but given you have a TAR archive like this: $ tar tf x.tar d1/ d1/sub1/ d1/sub1/file3 d1/file2 d2/ d2/file5 d2/sub1/ d2/sub1/file6 d2/sub1/subsub1/ d2/sub1/subsub1/file7 file1 and only want to restore the directory "d2", then this is it: $ tar xvf x.tar d2 d2/ d2/file5 d2/sub1/ d2/sub1/file6 d2/sub1/subsub1/ d2/sub1/subsub1/file7 Another hint - which is true for many GNU tools -: the man page is only a copy of "tar --help", and the full manual can be read as Texinfo manual, as also stated at the end of the man page: SEE ALSO The full documentation for tar is maintained as a Texinfo manual. If the info and tar programs are properly installed at your site, the command info tar should give you access to the complete manual. Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Linux Version: 3.2.30 OpenSUSE 12.2 tar (GNU tar) 1.26 I have a tar archive with the following example contents: root/ root/file1 root/file2 root/file3 .... My pwd is /example/. Here is a listing of my example directory: $ pwd /example/ $ ls $ whereiwanttoextractmyfiles/ $ example.tar.bz What I would like to happen is extract by first changing to the target directory which is whereiwanttoextractmyfiles/ and extract the contents of root/, so I end up with: whereiwanttoextractmyfiles/file1 whereiwanttoextractmyfiles/file2 whereiwanttoextractmyfiles/file3 Instead, neither '--levels=' nor '--strip-components' gave me the results I wanted, I ended up with this: whereiwanttoextractmyfiles/root/file1 whereiwanttoextractmyfiles/root/file2 whereiwanttoextractmyfiles/root/file3 I hope that I clear up the confusion -- Regards -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 01/24/2013 10:55 AM, General Mail wrote:
Linux Version: 3.2.30 OpenSUSE 12.2 tar (GNU tar) 1.26
I have a tar archive with the following example contents:
root/ root/file1 root/file2 root/file3 ....
My pwd is /example/. Here is a listing of my example directory: $ pwd /example/ $ ls $ whereiwanttoextractmyfiles/ $ example.tar.bz
What I would like to happen is extract by first changing to the target directory which is whereiwanttoextractmyfiles/ and extract the contents of root/, so I end up with:
whereiwanttoextractmyfiles/file1 whereiwanttoextractmyfiles/file2 whereiwanttoextractmyfiles/file3
Instead, neither '--levels=' nor '--strip-components' gave me the results I wanted, I ended up with this:
whereiwanttoextractmyfiles/root/file1 whereiwanttoextractmyfiles/root/file2 whereiwanttoextractmyfiles/root/file3
I hope that I clear up the confusion
Now, it's clear, thanks. What about this? $ tar xf example.tar.bz --strip-components=1 -C whereiwanttoextractmyfiles $ find whereiwanttoextractmyfiles/ whereiwanttoextractmyfiles/ whereiwanttoextractmyfiles/file1 whereiwanttoextractmyfiles/file2 whereiwanttoextractmyfiles/file3 Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 1/24/2013 5:37 AM, Bernhard Voelker wrote:
On 01/24/2013 10:55 AM, General Mail wrote:
Now, it's clear, thanks.
What about this?
$ tar xf example.tar.bz --strip-components=1 -C whereiwanttoextractmyfiles
$ find whereiwanttoextractmyfiles/ whereiwanttoextractmyfiles/ whereiwanttoextractmyfiles/file1 whereiwanttoextractmyfiles/file2 whereiwanttoextractmyfiles/file3
Have a nice day, Berny
Thanks allot Berny, that did the trick. It's much more simpler than the other suggestion. Funny, I had tried that and I must have missed something because it didn't work for me. Anyhow, thanks again. - Regards -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 01/24/2013 11:55 AM, General Mail wrote:
have a tar archive with the following example contents
- another work-around, maybe : - untar the files, somewhere - then use command like : tar clf - . | ( umask 0; cd /mnt; tar xvf - ) ............. - move to untared source directory to start with < tar clf - . > then , adjust /mnt to target directory. ............... best regards -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 1/24/2013 7:08 AM, DenverD wrote:
I hope that I clear up the confusion
is your question from assigned homework?
dd
No, it's not a Homework assignment. Allot packages I have on my box are in tar archives, I am look for easier way to accomplish a task more efficiently. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (5)
-
Bernhard Voelker
-
DenverD
-
ellanios82
-
General Mail
-
Per Jessen