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 |
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. |
Additionally, are you familiar with "cp -r" (or is it "cp -R"?), the cp that recursively copies a directory and its children?
|
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.
|
tar -zxvf tarball.tar.gz -C <directory>
C is capitol. |
All times are GMT -5. The time now is 04:22 AM. |