TAR command to extract a single file from a .tar.gz

gziptar

Does anyone have a command syntax for extracting 1 file from a .tar.gz that also allows me to place the extracted file in a certain directory? I have Googled this and get too many variations with a lot of forum threads stating the syntax doesn't work. Before I venture on I prefer to know the command will work because I do not want to risk overwriting files and directories already present on my server.

Best Answer

If you're risking overwriting files in production with uncertain results, you're doing something wrong. Test first.

tar zxvf archive.tar.gz path/to/file/in/archive -C /destination/dir

Related Topic