#!/bin/bash
# pair=even; impair=odd

usage() {
	echo "$0 help"
	echo ""
	echo "Syntax:"
	echo "    $0 <character> <file>"
	echo ""
	echo "If the number of <character> into a line of <file> is odd,"
	echo "$0 will output the name of <file> and that line."
	echo "If <character> is a quote, it need to be escaped:"
	echo "    \'"
	
	exit 1
}

if [ $# -ne 2 ]; then
	usage
fi

#echo "This is a testing line \
#"	on 2 lines."

findodd() {
while read myline ; do
	rest="${myline//[^$1]}"
	count="${#rest}"
	if [ $((count%2)) -ne 0 ]; then
		echo "$2 ${myline}"
	fi
done < "$2"
}

findodd $1 "$2"
