Originally posted by: SystemAdmin
Unfortunately, it looks like the -C flag is not intended to be used when un-archiving files:
[i]-C Directory Causes the tar command to perform a chdir subroutine to the
directory specified by the Directory variable. Using the -C flag allows multiple
directories not related by a close common parent to be [b][u]archived[/u][/b], using short
relative path names. For example, to archive files from the /usr/include and
/etc directories, you might use the following command:
tar c -C /usr/include File1 File2 -C /etc File3 File4
The -CDirectory flag must appear after all other flags and can appear in the
list of file names given.[/i]
I would suggest wrapping the command with other commands to change to the directory before executing tar and then to change back afterwards, e.g.
code#x=$(pwd); cd /dest/dir; tar -xvf /path/tarfile; cd $x[/code]
I cannot think of any other way to do this than to manually execute separate commands.