Update an existing tar archive with new or changed files.
You can use this short tar command.
tar -uvf files.tar files/my-file.txt
Or this more verbose tar command.
tar --update --verbose --file files.tar files/my-file.txt
Note: The above will only work on uncompressed tar archives. Ie. files.tar
.
To update a file in a compresed archive Ie files.tar.gz
, you'll need to extract the .tar.gz
file to a .tar
before you update the file.
u
or --update
tells tar to add to the archive if the modification time is newer than in the archivev
or --verbose
tells tar to produce verbose outputf
or --file
tells tar that the next parameter will be the tar file to create, extract, append to, list, etc.