Removing Null data in output

Hello all,

I have a script that has an infile with system package information. For the most part the script is looking well. The only thing i need help is in testing for null entries and removing null data.

#!/usr/bin/ksh

for i in `cat /mwncps/bin/eco_pack`

do

NAME=`pkginfo -l | grep $i | grep 'NAME' | awk '{ print $5 }'`
VER=`pkginfo | grep $i | grep version | awk 'BEGIN {OFS=" "}{gsub(/version:/,"") ;}{ print $7 }'`

echo "`hostname`,"$NAME","$VER""

done

The output now looks like this

hostname,,
hostname,,
hostname,package,version <-- this part of the output is correct
hostname,package,version
hostname,package,version
hostname,package,version
hostname,, <-- this will need to be removed completely
hostname,,

I welcome your feedback

Regards,

Al

try something like this

#!/usr/bin/ksh

while read i
do

  	NAME=`pkginfo -l | grep $i | grep 'NAME' | awk '{ print $5 }'`
  	VER=`pkginfo | grep $i | grep version | awk 'BEGIN {OFS=" "}{gsub(/version:/,"") ;}{ print $7 }'`
	if [[ -z $NAME ]]; then
   		continue
   	fi	
	echo "`hostname`,"$NAME","$VER""

done < /mwncps/bin/eco_pack > outputfile


I just incorporated this portion

if [[ -z $NAME ]]; then
continue
fi
and that did the trick.

Many thanks,

Al:)