LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-01-2015, 11:35 AM   #1
mrrhq
LQ Newbie
 
Registered: Oct 2011
Posts: 23

Rep: Reputation: Disabled
force tar clobbering (overwrites) with -C


Hey, I want to find a way to use the tar utility to overwrite to a destination directory.

For example, I have a tar bzip2 here that I extract.
Quote:
tar xvjf archive.tar.bz2 -C newdir
And let's say the original root directory of archive.tar.bz2 is called originaldir...

What happens is this directory is created in newdir:

Quote:
/path/to/newdir/originaldir
But I want to overwrite all files in newdir with -C newdir:

Quote:
/path/to/newdir
Newdir should be the same as originaldir, but with newer files clobbering the old, and leaving the original ones alone.
Maybe I can do something after extracting, like rsync -av from originaldir to newdir and removing it, but it seems too wierd. Also, I don't think -O will do what I want, and it's not clear how to use it. Any help?
 
Old 02-01-2015, 11:52 AM   #2
mrrhq
LQ Newbie
 
Registered: Oct 2011
Posts: 23

Original Poster
Rep: Reputation: Disabled
Sorry, I found the answer I was looking for. It's this:

Quote:
tar xvjf archive.tar.bz2 -C newdir --strip-components=1
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
clobbering a directory with mv Xinc Linux - Newbie 3 12-06-2012 02:43 PM
LXer: Intel: Samsung Clobbering Others With Tizen LXer Syndicated Linux News 0 10-06-2012 09:40 AM
How can I force tar to over-write busy files? KenShelby Linux - Newbie 12 06-17-2009 06:36 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration