Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

result of command I am running 1

Status
Not open for further replies.

amasj

Programmer
Nov 9, 2019
1
US
result of command

I am running job which creates a .gz file. e.g. xyz.gz

When I use below command result always vary.

wc -l xyz.gz

count = 30
count =50

does this mean data is also varying in the file ?
 
I don't believe using word count on a compressed file makes sense. Anyone else have an opinion?

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
A Gzip file is a binary file and getting a line count is worthless. What are you actually trying to do? Are you attempting to get the size of the file? (ls -la xyz.gz), Are you seeing if it is different from before (cksum xyz.gz) What exactly are you trying to do by using the wc command


Bill
Lead Application Developer
New York State, USA
 
As already mentioned, a Gzip file is a compressed binary file. The "[tt]wc -l[/tt]" command is trying to find lines in a text file. You won't get anything meaningful.

If you want to know how many files are in the [tt].gz[/tt] file, these commands can do that...

Code:
zipinfo -1 xyz.gz | wc -l

zipinfo xyz.gz | tail -1

 
does this mean data is also varying in the file?

If two files are EXACTLY the same, then their compressed (gz) files should be exactly the same, and the wc command should return exactly the same result. If even 1 byte changes in the file, the wc command could return a different result for each file.

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
The only way to really know if the 2 files are the same is to compare their checksums.

cksum FILE1
cksum FILE2



Bill
Lead Application Developer
New York State, USA
 
What Bill says is true. If you are interested in verifying that the files are identical, his is the only sure solution.

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
How is that "the only sure solution"? What about
Code:
/usr/bin/cmp
?
 
yes cmp will work just fine. The reason that I use cksum almost exclusively is that I store the checksums into a database so that I can make sure that all duplicates never get passed.

Bill
Lead Application Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top