Search This Blog

Wednesday, November 21, 2018

How to extract tar file to different folder

Only when the the path of files saved in the tar file is relative can you extract them to different folder.
Check it is relative or not using:
tar tvf /paht/your-tar-file.tgz
If the path is relative,
cd  /your/extract/folder
tar xvzf /path/your-tar-file.tgz 
Or just run:
tar xvzf /path/your-tar-file.tgz -C /your/extract/folder
Or
tar xvzf /path/your-tar-file.tgz --directory /your/extract/folder