Hi Folks,
I have a tar.gz compressed file with me, and I want to know the number of files in the archive without uncompressing it.
Please let me know how I can achieve it.
Regards
RK Veluvali
Hi Folks,
I have a tar.gz compressed file with me, and I want to know the number of files in the archive without uncompressing it.
Please let me know how I can achieve it.
Regards
RK Veluvali
use tar -vft tarfile to see the content and size of the file
Without decompressing it, you can't. The compressed data is meaningless to tar. You'll have to pipe it through gunzip before doing a 'tar -tf -'.
Nobody's mentioned the O/S or how the data was compressed.
A general answer is a combination of the above posts. You have to decompress but it can be to a pipeline through "zcat".
The switches to the "tar" are:
t = list files rather than extract them
f = filename of archive (in this case "-" which means read from pipeline).
zcat tarfile.gz | tar -tf - | wc -l
The OS probably isn't important in this case since nonportable flags like -z haven't been suggested. And given the gz, it's safe to assume the compressor was gzip.
Many unixes won't accept "-" in a parameter to "tar".
Never assume anything. (Tongue firmly in cheek).