untar selcted files from archive
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a 'test.tar.gz' file, which contains, for example, 10 files. They are '001.nc', '002.nc', ..., '010.nc'.
I can use 'untar' to uncmpress all 10 files into folder. But if I only need one file in the archive, say, '002.nc', and untarring all files will be a waste time, especially when the tar file is extremely big.
Is there any way I can select which files to untar and skip the rest?
btw, I tried to edit the 'untar' function, but couldn't find a place where I can add such an input argument.
Is there anybody who has any ideas?
Thank you a lot. Mike
0 commentaires
Réponses (1)
Walter Roberson
le 3 Jan 2012
It appears to me that if you went in to untar.m and modified getNextEntry, you could have it check the received name and go back to do tarInStream.getNextEntry() if it did not match.
Myself, I wouldn't bother doing that, but then I'm using Unix systems where I can gzip and pipe that in to tar -x specifying the names I want to retrieve.
2 commentaires
Walter Roberson
le 3 Jan 2012
Modify that routine to use a "while true" loop. Have the "entry =" assignment first thing inside that loop. Validate the entry like it shows. Add an "elseif isempty(entry)" to the validation, and break out of the loop when it occurs; then "else", getEntryName(entry); compare the returned entry name to the file names you are looking for, and if it is one of them then break out of the loop (and otherwise allow the loop to continue so it will get the next entry)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!