#!/bin/ksh awk -v check_val="$1" '{ if( $0==check_val) { key[$0]++ } if(key[$0] < 2 ) print $0 }' inputfile > outputfile