PDA

View Full Version : How to list .tar archive contents and extract only selected folders/files?



Fli
07-27-2014, 11:58 AM
Hello,

i have 40gb large tar.gz archive with huge directory trees. Please can anyone advice on how to list this archive contents without taking server resources to extract entire archive?

I would prefer if i can list only root directory. like:

archive.tar.gz :
docs
images
videos
games
file1
file2
file3

then when i see what is inside root, i want to example list only /docs folder content, but not list subdirectories and sub files of that docs folder..

Also please how to extract only certain directory/es or file/s from this archive?

Thank you

UPDATE:

one can try this to list only certain directory:

tar --list --verbose --no-recursion --file=archive.tgz ./foldernametolist/*
or

tar tf archive.tgz ./foldernametolist/*

to extract some folder:

tar xf archive.tgz ./folder/subfolder_to_extract/