Size of compressed file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Size of compressed file
# 1  
Old 07-17-2015
Size of compressed file

Hi All,

Is there is any way to find the size of compressed file without doing decompression. The size should give the original uncompressed data size

Thanks
Arun
# 2  
Old 07-17-2015
Code:
gunzip -l file.gz

will help you.
# 3  
Old 07-21-2015
Depending on the tool used for compression, the above may do it, but you may also need to consider:-
Code:
zcat file.Z | wc


Robin
# 4  
Old 07-21-2015
Hi.

The utility p7zip can deal with many forms of compression:
Code:
 List of supported formats:
   - Packing / unpacking: 7z, ZIP, GZIP, BZIP2, XZ and TAR
   - Unpacking only: APM, ARJ, CAB, CHM, CPIO, CramFS, DEB, DMG, FAT,
     HFS, ISO, LZH, LZMA, LZMA2, MBR, MSI, MSLZ, NSIS, NTFS, RAR (only
     if non-free p7zip-rar package is installed), RPM, SquashFS, UDF,
     VHD, WIM, XAR and Z.

For example:
Code:
$ file t1.zip 
t1.zip: Zip archive data, at least v2.0 to extract

running 7z on this file with "list" directive produces:
Code:
$ 7z l t1.zip 

7-Zip  4.58 beta  Copyright (c) 1999-2008 Igor Pavlov  2008-05-05
p7zip Version 4.58 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU)

Listing archive: t1.zip


   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2010-06-07 09:23:38 .....          160          126  t1.sas7bdat
------------------- ----- ------------ ------------  ------------------------
                                   160          126  1 files, 0 folders

More recent versions, around 9.x, are available in repositories (e.g Debian, SuSE, CentOS, Mac OS X ("brew"), etc).

I don't know if every compression format includes meta-data that can be extracted without uncompressing the file, but p7zip seems worth a try.

The run was in the environment:
Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian 5.0.8 (lenny, workstation)

Best wishes ... cheers, drl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding file to compressed tarfile

Hello all, I would like to add a file to a compressed (gzip) tarfile. Normally it won't be a Problem, if I would do it in several steps. But I do not want to have unnecessary files. So, in words: unzip the tarfile add a new file zip the tarfile What I tried: ... (3 Replies)
Discussion started by: API
3 Replies

2. Shell Programming and Scripting

Is there any way to find the compressed size of a file without compressing it in linux

i need to backup a directory from one partition to another and and compress that directory after backing up, so i need to predict the compressed size of the directory with out actually compressing it, to check whether the space is available in the destination partition to accommodate the zipped... (2 Replies)
Discussion started by: Kesavan
2 Replies

3. Shell Programming and Scripting

compressed file

i have a file 4d7a94d0.bbb.1292 when i do file 4d7a94d0.bbb.1292 the ouput is below 4d7a94d0.bbb.1292: gzip compressed data - deflate method and i run this command gunzip -c 4d7a94d0.bbb.1292 | awk '{gsub("\"","")}/I_ACCOUNT_ID/{print $2}' RS=":|;" FS="," i get... (3 Replies)
Discussion started by: blackzinga80
3 Replies

4. Shell Programming and Scripting

Process a compressed file

Hi i have a filename.tar.bz2 and i have to parse it with a tool that doesn't support compressed files. I have to do it for many big files, so i can't decompress and then process. I'd like to do something like: tar -jxvf namefile.tar.bz2 | parsing_tool i mean analyze it directly,... (4 Replies)
Discussion started by: Dedalus
4 Replies

5. Shell Programming and Scripting

Find all tar and compressed file

Hi, I'm trying to find all tar and compressed files (say gzip). I'm having to assume that the tar and gzip files may or may not have the correct extension (.tar .gz .tgz etc). Any help appreciated (2 Replies)
Discussion started by: andyatit
2 Replies

6. UNIX for Dummies Questions & Answers

compressed file

I compressed a file by using gzip command gzip <<xx>> filename changed to xx.gz How to view this xx.gz file. Any idea. Thanks in advance. (7 Replies)
Discussion started by: venkatesht
7 Replies

7. UNIX for Advanced & Expert Users

Is it possible to see the content of the compressed file?

How we can view the content of the file,if it compressed (or) Zipped ,without uncompress ? I have one file ,i compressed it,without uncompressing the file.Is it possible to see the content of the file? (2 Replies)
Discussion started by: bobprabhu
2 Replies

8. UNIX for Advanced & Expert Users

Search first line of compressed file

I want to read a directory full of compressed files and move the file to another directory if it meets certain criteria. I only want to look at the first line of the compressed file and if I find the string, do the move. I am currently using the following: zgrep -R -L... (1 Reply)
Discussion started by: cbreiner
1 Replies

9. Shell Programming and Scripting

Check if file compressed or not

Is there a way I can check if a file is comppressed or not? (Be it tar/gzip or compress). trying to write a generic housekeeping scrit that will delete files over 6 months old and compress any uncompressed files if less than 6 months old. But not sure if there is a clever way to check except for... (4 Replies)
Discussion started by: badg3r
4 Replies

10. UNIX for Dummies Questions & Answers

renaming a compressed file to filename without .Z

In a shell script I would like to use a compressed file name, i.e. with suffix of .Z, as a file input $1. After the file in uncompressed, I would like to use the file name without the .Z . How do I do this? Thank you. (8 Replies)
Discussion started by: bruceps
8 Replies
Login or Register to Ask a Question