LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 12-04-2006, 11:12 AM   #1
kennmurrah
LQ Newbie
 
Registered: May 2005
Posts: 20

Rep: Reputation: 0
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
 
Old 12-04-2006, 11:58 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,024
Blog Entries: 5

Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
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.

Last edited by MensaWater; 12-05-2006 at 11:11 AM.
 
Old 12-04-2006, 02:04 PM   #3
Tralce
Member
 
Registered: Nov 2006
Location: Maine
Distribution: Debian, Ubuntu, Gentoo
Posts: 109

Rep: Reputation: 15
Additionally, are you familiar with "cp -r" (or is it "cp -R"?), the cp that recursively copies a directory and its children?
 
Old 12-04-2006, 02:27 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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.
 
Old 05-22-2010, 07:06 AM   #5
kresso
LQ Newbie
 
Registered: May 2010
Posts: 1

Rep: Reputation: 0
tar -zxvf tarball.tar.gz -C <directory>

C is capitol.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
proftpd allow user to specific folder GUIPenguin Linux - General 4 05-18-2006 07:41 PM
Untar File to a specific location ! Libu Linux - General 3 12-19-2005 08:14 PM
Jailing a user to a specific folder ONLY GUIPenguin Linux - Security 3 09-23-2005 07:16 AM
How do I FTP into specific folder hrp2171 Slackware 3 10-18-2004 08:30 PM
domain pointing to a specific folder dominant Linux - Software 3 01-28-2004 03:49 AM


All times are GMT -5. The time now is 04:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration