2

I was trying to use tar command , --delete option and met some problems. There are two things I don't understand:

  1. when using --verbose option with combination of --delete option, nothing shows as --verbose usually do, i.e. no show of deleted files.
  2. when using --totals option, the deleted size is always 0, it doesn't make sense and I can't figure out the meaning of these output.

Can anyone help me with these? The following code shows the procedure.

x@x:~/bin$ tar --list --file=pomo.tar
pomodoro
pomodoro_2
pomodoro_3
x@x:~/bin$ tar --append --file=pomo.tar quitpomo --verbose
quitpomo
x@x:~/bin$ tar --list --file=pomo.tar
pomodoro
pomodoro_2
pomodoro_3
quitpomo
x@x:~/bin$ tar --list --file=pomo.tar --totals
pomodoro
pomodoro_2
pomodoro_3
quitpomo
Total bytes read: 10240 (10KiB, 12MiB/s)
x@x:~/bin$ tar --delete --file=pomo.tar quitpomo --total --verbose
Total bytes read: 10240 (10KiB, 86MiB/s)
Total bytes written: 10240 (10KiB, 86MiB/s)
Total bytes deleted: 0
1

If you look at the size of the .tar file before and after the --delete, you will see that there is no change in filesize. Hence the total bytes deleted is 0.

If you make the file quitpomo larger ( I tried 20480 bytes ), add it and then delete it using the same commands, you will have a non-zero "Total bytes deleted"

This is caused by (GNU)tar using a block structure which adds a certain overhead, and deleting something that doesn't change the block count is considered as not having deleted any bytes (relative to the total file size, not of course to the combined size of files stored internal to those blocks).

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.