All commands tested on Mac OS Monterey / Jan 05, 2022

How to extract a tar archive into a different directory

Extract files.tar to the directory ~/some-other-directory.

You can use this short tar command.

              
                  tar -xvf files.tar -C ~/some-other-directory-somewhere
              
          

Or this more verbose tar command.

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

Options explained

  1. -x or --extract tells tar to extract 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.
  4. -C, --cd or --directory tells tar to change (cd) into the directory before creating, listing, extracting, appending to etc. the archive

More commands for extracting from tar archives