LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   untar to a specific folder (https://www.linuxquestions.org/questions/linux-general-1/untar-to-a-specific-folder-507383/)

kennmurrah 12-04-2006 10:12 AM

untar to a specific folder
 
Greetings.

I'm trying to move IMAPed files from my old mail server to the new one. I began by tarring my old mail directory:

tar cvf kmurrah.tar /home/vmail/kmurrah@usseryprinting.com/*


then moved the file to the new mail server. Then I uncompressed it by going to /home/kmurrah and using

tar xvf kmurrah.tar

problem is, I now have the files untarred at /home/kmurrah/home/vmail/kmurrah@usseryprinting.com and there are so many of them, I can't cp them to the folder I want them in.

So, my question is this: is there a command I can use in either tarring or untarring that allows me to put the files in the directory I want? that is, so that the files can be untarred "loose" into whatever folder I want them in, not inside another folder?

I hope I've made my question clear.

Thanks in advance for the help.

Kenn

MensaWater 12-04-2006 10:58 AM

tar xvf kmurrah.tar --strip-components 3

The "strip-components 3" tells it to remove the 3 leading directories from the filename. Note on older GNU tar it was --strip-path instead of --strip-components.

FYI type "man tar" for full details of its usage including the above.

Tralce 12-04-2006 01:04 PM

Additionally, are you familiar with "cp -r" (or is it "cp -R"?), the cp that recursively copies a directory and its children?

matthewg42 12-04-2006 01:27 PM

Don't copy the files after untarring them - mv them. As long as you're not moving to a different device, the operation is very quick.

kresso 05-22-2010 06:06 AM

tar -zxvf tarball.tar.gz -C <directory>

C is capitol.


All times are GMT -5. The time now is 04:22 AM.