All commands tested on Mac OS Monterey / Jul 02, 2024

How to update a tar archive with new or changed files

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.


Options explained

  1. u or --update tells tar to add to the archive if the modification time is newer than in the archive
  2. v or --verbosetells tar to produce verbose output
  3. f or --filetells tar that the next parameter will be the tar file to create, extract, append to, list, etc.

More commands to update tar archives