TransWikia.com

tar --remove-files behavior: delete after every file or after completion?

Super User Asked on November 24, 2021

Pretty much in the title. I have a box with very little disk space left and lots of data. I want to add all of the files into a tar, deleting them as I go because there is clearly not enough space to get it all in without deleting the data. So, using the tar –remove-files option should work, if it deletes after it adds each file, not deleting after it completes the entire archive.

It’s not sensitive data, just movies and music so I decided to run it anyway, so I’ll find out in a while, but if anyone knows, it will certainly set my mind at ease if they could answer. If not, I’ll post my findings once it’s completed or failed miserably.

2 Answers

It is not written clearly in the manual page. From my experience, neither is true. It does not delete files after adding immediately, but seems to do so after some delay (time, or file size, or the number of files, I don't really know). It definitely started deleting before completion as my hard disk is not large enough to hold both all the original files and the tar.

For reference, I am using GNU tar 1.28.

OP, people on the Internet would definitely appreciate it if you did "post your findings" some 8 years ago :)

Answered by hkchengrex on November 24, 2021

I'm having a similar problem so I tried doing strace on tar remove-files acting on 2 files. In this case it seems like unlink is called by the system in the end, so that would mean that tar is first archiving and then deleting. This is of course not a conclusive test, but at least a hint. You could try the same thing but with more files and look if tar acts differently in that case.

Answered by YotaMHzYota on November 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP