How to overwrite existing files by using tar command (Remove extra files)
Hello,
I want to overwrite files by using tar command. But I also want to remove extra files. for example: Original files. a/1,2 TAR files a/1' After extraction a/1' (Because there is no "2" file in tar file. My question is how to delete file "2" by using tar. |
since you are overwriting files, and want to delete files that aren't in the tar file - the EASIEST way is to just delete everything first.
|
Hi Kalibo, Welcome to LQ.
try this. Code:
tar --delete -f a.tar a/2 |
Is there no other way to delete files that aren't in the tar file after extraction?
There is too risky to delete everything before extraction behavior... Quote:
|
Thank you for reply.
But actually, I want to delete files that aren't in the tar file. This command is proposed to delete file which is in the tar. Quote:
|
Quote:
|
Sorry for unclear statement.
For example. I have two files under directory A. A/aaa.txt A/bbb.txt 1. tar directory A without aaa.txt to backup.tar => backup.tar *(without aaa.txt)* 2. Untar backup.tar to directory A A/aaa.txt -> Not in backup.tar A/bbb.txt -> Update from backup.tar I want to remove aaa.txt because there is no aaa.txt file in backup.tar Quote:
|
Quote:
Same result. |
jpollard,
Thank you for reply. Because I dont have enough disk size to allocate two directories... Quote:
|
Quote:
The option -u is there for tar. Its used to update the tar archive with new file. And then delete/dont include the aaa.txt. Try this: PHP Code:
PHP Code:
|
All times are GMT -5. The time now is 09:14 AM. |