append or remove file from tar and tar.gz
6,780
-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
Related videos on Youtube
Author by
Mohammad Kholghi
Updated on September 18, 2022Comments
-
Mohammad Kholghi over 1 year
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 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
orfile.tar.bz2
orfile.tar.xz
? Is there any command or I should always untar and tar again?
Edit:
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
-
pLumo over 5 yearsplease next time ask separate questions as it's easier to answer and easier to find for others.
-
Mohammad Kholghi over 5 years@RoVo questions where related together, but next time OK. Tnx for recommendation.
-