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 existing files when extracting

which one is used by default?


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 ?

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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