How does tar.gz file gets uncompressed with all contents to arbitrary directory, existing or not using tar using single line command? If it does not exists, then is created (directory). To clarify, let consider example:I've downloaded archive-latest.tar.gz from internet into directory /home/user/Downloads. I have microSD card target partition mounted on /mnt/archive. Once downloaded, I want to extract downloaded /home/user/Downloads/archive-latest.tar.gz directly on /mnt/archive using single line command. I've read man tar manual, but I cannot find option for specifying target dir.
Uncompressing .tar.gz archive to specific directory
directory;tar
The -C option makes tar change to an existing directory before starting to extract: tar xv -C /mnt/archive -f /home/user/Downloads/archive-latest.tar.gzIf you are already located in the directory /home/user or /home/user/Downloads you can shorten the path after -f accordingly.If there is a chance the target path doesn't exist you can created it with mkdir: mkdir -p /mnt/archive;  tar xv -C /mnt/archive -f /home/user/Downloads/archive-latest.tar.gzWith the -p option mkdir doesn't complain in case the directory already exists.