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

How to append a directory to an existing tar archive

Add a directory ~/some-other-directory to an existing files.tar archive.

You can use this short tar command.

              
                  tar -rvf files.tar ~/some-other-directory-somewhere
              
          

Or this more verbose tar command.

              
                  tar --append --verbose --file files.tar ~/some-other-directory-somewhere
              
          

You can append multiple directories onto an exsiting tar archive by simply chaining the directories.

              
                  tar --append --verbose --file files.tar ~/some-other-directory-somewhere ~/another-directory-somewhere
              
          

Options explained

  1. -r or --append tells tar to append to an existing 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 for appending to tar archives