Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

In the documentation, I read that tar has the following options when extracting files from a tarball:

-k, --keep-old-files
           don't replace existing files when extracting
--overwrite
           overwrite existing files when extracting

which one is used by default?

share|improve this question

1 Answer 1

up vote 10 down vote accepted

You can try it by yourself:

echo 1 > 1
echo 2 > 2
tar cf foo.tar 1 2
echo 3 > 1
echo 4 > 2
tar xf foo.tar
cat ?
1
2

First two files (1 and 2) were created. Than an archive foo.tar was created. The next step changed the file contents and after that foo.tar was extracted. If you look into the files you'll see the old contents.

So --overwrite is default.

share|improve this answer
    
Thanks @qbi. Interestingly my intuition was wrong. –  Amelio Vazquez-Reina Apr 27 '11 at 13:04
4  
the default is: --overwrite-dir overwrite metadata of existing directories when extracting (default) –  janwen Oct 8 '13 at 7:35
1  
And an explanation of the behavior: gnu.org/software/tar/manual/html_node/… –  ernie Mar 4 at 19:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.