#!/bin/bash
#
# lc file [nempty,1]
#
# count the lines of a file. if file doesn't exist, return 0
#
# if nempty is unity (default), will only count non-empty lines, else all lines
#
# $Id: lc,v 1.3 2002-12-18 10:14:03-08 becker Exp tbecker $
#
nempty=${2-1}
if [ ! -s $1 ];then # non-existing files return 
#    echo -1
    echo 0
    exit
fi
if [ $nempty -eq 1 ];then # want only non-empty lines
    cat $1 | gawk '{if($1!="")print($0)}' | wc -l | \
	gawk '{print($1)}'
else
    cat $1 | wc -l | gawk '{print($1)}'
fi



