I need to extract the contents of a tar.gz file to a different destination folder in Linux? Is it possible in a single command?
You can use the -C or the –directory flag to specify a destination directory like this.
tar -xf yourfile.tar.gz -C /var/www/
Thanks Vipin. Is there a way to discard the parent folder in the archive and extract only the inner files/folder of the archive?
My archive is
ojs-3.3.0-5.tar.gz. When I extract this to /var/www/ojs/ folder with this command
tar -xf ojs-3.3.0-5.tar.gz -C /var/www/ojs/, I am getting an
ojs-.3.3.0-5 folder inside
/var/www/ojs/. Is there a way to avoid this and have the inner files and folder alone?