Gzip is standard file compression in unix but many file or source code is packeted in tarball and compressed with gzip (tar.gz). Now we want get detail information from tar.gz from shell script.
We have tar.gz file and we want to know detail information in this file.
Open shell script because we played in command mode.
root@hardy:/home# ls -l currenttrack-1.2.tar.gz
-rwx------ 1 bearisusanto root 474768 2008-09-09 18:16 currenttrack-1.2.tar.gz
root@hardy:/home# file currenttrack-1.2.tar.gz
currenttrack-1.2.tar.gz: gzip compressed data, from Unix, last modified: Tue May 22 14:04:06 2007, max compression
If we want to know file type, add -z option in command:
root@hardy:/home# file -z currenttrack-1.2.tar.gz
currenttrack-1.2.tar.gz: tar archive (gzip compressed data, from Unix, last modified: Tue May 22 14:04:06 2007, max compression)
From information we know that currenttrack-1.2.tar.gz is gzip file which maximally compressed, where contain a tar file.
Get file contain
Now we want get the file contain without extracted. The easy way is with -t(list) option which has by tar program, combinated with -z (gzip file) and -f (file name) like below:
root@hardy:/home# tar ztf currenttrack-1.2.tar.gz
currenttrack-1.2/
currenttrack-1.2/README
currenttrack-1.2/protocols/
currenttrack-1.2/protocols/Makefile.in
currenttrack-1.2/protocols/Makefile.am
currenttrack-1.2/protocols/msn/
currenttrack-1.2/protocols/msn/user.h
.......etc
To get amount of line, use wc program
root@hardy:/home# tar ztf currenttrack-1.2.tar.gz |wc -l
118
To get information like this:
1.Compression file
2.Un-compression file
3.Compression ratio
4.Un-compression file name
5.Compression method (deflate,compress,lzh, & pack)
6.CRC
7.Date
8.Time
Just running gzip program with -l(list) option combinated with -v(verbose)
root@hardy:/home# gzip -vl currenttrack-1.2.tar.gz
method crc date time compressed uncompressed ratio uncompressed_name
defla cdbbf3ae Sep 9 18:16 474768 2775040 82.9% currenttrack-1.2.tar
Custom Search
Friday, January 2, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment