views:

150

answers:

1
+1  Q: 

wc gzipped files?

I have a directory with both uncompressed and gzipped files and want to run wc -l on this directory. wc will provide a line count value for the compressed files which is not accurate (since it seems to count newlines in the gzipped version of the file). Is there a way to create a zwc script similar to zgrep that will detected the gzipped files and count the uncompressed lines?

+5  A: 

Try this zwc script:

#! /bin/bash --
for F in "$@"; do
  echo "$(zcat -f <"$F" | wc) $F"
done
pts
It should be "echo "$(zcat -f <"$F" | wc -l) $F"
Reef
Thanks, this works great.
pseinstein
or $(zgrep -c "" $F)
Chas. Owens