Dec 06

linux — How to extract specified file/directory from a tar ball

well,you got a big tar ball file,but in fact you only need some special file or directory.Then you don’t want to extract  all files from the tar ball if it’s a big file.so how to get specified file or directory from a tar ball?

tar command allows to extract a single file or directory using the following format. It works under UNIX, Linux, and BSD operating systems.

tar xvf big.tar filename
tar -zxvf abc.tar.gz directory-name
tar -zxvf abc.tar.gz path/to/directory-name -C /tmp

Keep in mind that both the filename and directory-name should be existed in the tar ball file,and the path is relative to the tar ball root.