Tar - Extract Tar Files To a Different Directory


Typical Unix tar syntax:
tar -xf file.name.tar -C /path/to/directory


GNU/tar Linux syntax:
tar xf file.tar -C /path/to/directory


OR
tar xf file.tar --directory /path/to/directory

Where,

  • x : Extract files
  • f : Tar archive name
  • --directory : Set directory name to extract files
  • -C : Set dir name to extract files
  • -z : Work on .tar.gz (gzip) file format
  • -j : Work on .tar.bz2 (bzip2) file format
  • -J (capital J) : Work on .tar.xz (xz) file format
  • -v : Verbose output i.e. show progress on screen

SourceURL:https://www.cyberciti.biz/faq/howto-extract-tar-file-to-specific-directory-on-unixlinux/

Version:0.9 StartHTML:0000000205 EndHTML:0000007479 StartFragment:0000000241 EndFragment:0000007443 SourceURL:https://www.cyberciti.biz/faq/howto-extract-tar-file-to-specific-directory-on-unixlinux/

Where,

  • x : Extract files
  • f : Tar archive name
  • --directory : Set directory name to extract files
  • -C : Set dir name to extract files
  • -z : Work on .tar.gz (gzip) file format
  • -j : Work on .tar.bz2 (bzip2) file format
  • -J (capital J) : Work on .tar.xz (xz) file format (see how to extract tar.xz files in Linux for more details)
  • -v : Verbose output i.e. show progress on screen
tar