perl -ne 'm/($find)/ and $x{$1}++}{print qq|FIND=$find;\n|;print qq|$_\t$x{$_}\n| for sort keys %x' -s -- -find=var1\|var2\|var3 YourFileName.txt