Hi,
I have some data files in a zipped format.(eg: aa.gz).I would like to know the number or rows in each zip file(May be populate the file name and line numbers into a text file).I know the commands wc -l and gunzip,.But how I will create a shell script for this to extract each files and get row count?I am using ksh.
I modified slightly.It prints.But for the rowcount, it is giving as 0 always.Any inputs?
#!/usr/bin/ksh
OUTFILE=infofile
cd /home/XYZ/ASH/;
for i in /home/XYZ/ASH/*.gz ;
do
ROW_COUNT=`zcat /home/XYZ/ASH/$i| wc -l`
printf "%-10s%s\n" "${ROW_COUNT}" "$i" >> $OUTFILE
done
exit 0
#!/usr/bin/ksh
OUTFILE=infofile
cd /home/XYZ/ASH/
for i in *.gz
do
ROW_COUNT=`zcat /home/XYZ/ASH/$i| wc -l`
printf "%-10s%s\n" "${ROW_COUNT}" "$i" >> $OUTFILE
done
exit 0
'ls' is useless here. Also you don't need a trailing ';'
#!/usr/bin/ksh
OUTFILE=infofile
for i in /home/XYZ/ASH/*.gz
do
ROW_COUNT=$(zcat "${i}" | wc -l)
printf "%-10s%s\n" "${ROW_COUNT}" "$i" >> $OUTFILE
done