2009-11-17

tar extract single file

Good to know how to extract a single file from a big archive.

List the content of the tar archive

for tar archives
tar -tvf archive.tar

for tar.gz archives
tar -ztvf archive.tar

for tar.bz2 archives
tar -jtvf archive.tar

Then to extract the single file
tar -ztvf archive.tar.gz # to see the whole archive
tar -zxvf archive.tar.gz /root/my/file.txt # to get the file or directory
tar -zxvf archive.tar.gz {path/to/file}

might be wise to use -C target_dir aswell so we dont overwrite it!

No comments:

Post a Comment