How To Extract a Tar Files To a Different Directory

Extract files to another directory

tar xf file.tar -C /path/to/directory
tar xf file.tar –directory /path/to/directory

To extract a foo.tar.bz2 (.tbz, .tbz2 & .tb2 extension file) tarball to /tmp/bar, enter:

mkdir /tmp/bar
tar -jxvf foo.tar.bz2 -C /tmp/bar

To see a progress pass the -v option:

tar -xvf $HOME/etc.backup.tar -C /tmp/data

Extract specific files too use:

tar -xvf $HOME/etc.backup.tar file1 file2 file3 dir1 -C /tmp/data