I want to append files to foo.tar:

tar -rvf foo.tar IMG_1807.MOV

this works, but when I want to remove files:

tar -dvf foo.tar IMG_1807.MOV

doesn't work. It shows the output:

Terminal:~/Desktop$ tar -dvf foo.tar IMG_1807.MOV 
Terminal:~/Desktop$ tar -tvf foo.tar
-rw-rw-r-- user/user    33084363 2018-12-19 03:02 IMG_1807.MOV

but doesn't delete anything. What should I do?

Second, how can I add or remove files from file.tar.gz or file.tar.bz2 or file.tar.xz? Is there any command or I should always untar and tar again?


Third: How to extract a specific file from a zipped file? Or how to extract from tar in a specific location? This did NOT work:

 tar -xvf foo.tar IMG_1807.MOV -C /path/to/destination
  • 1
    please next time ask separate questions as it's easier to answer and easier to find for others.
    – pLumo
    Dec 19, 2018 at 15:57
  • @RoVo questions where related together, but next time OK. Tnx for recommendation. Dec 19, 2018 at 17:24

1 Answer 1


-d is not delete but diff.

From man tar:

 -d, --diff, --compare
       find differences between archive and file system

use --delete.

tar --delete -vf foo.tar IMG_1807.MOV

You cannot update a tar.gz file, see this and this.

Regarding your question how to extract to specific location:

You must follow the correct command line order. -C as an option goes before [pathname]. See man tar for more information. The following works:

tar -xvf foo.tar -C /path/to/destination IMG_1807.MOV

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.