#!/bin/sh INFILE=test.in # get number of lines not matching "^#" (-v inverses the results) non_comment_lines=$(cat $INFILE | grep -cv "^#"); if [ 0 -lt $non_comment_lines ]; then perl ./process_file.pl < $INFILE fi