writing shell script to find line of invalid characters

Hi,

I have to write s script to check an input file for invalid characters. In this script I have to find the exact line of the invalid character. If the input file contain 2 invalid character sat line 10 and 17, the script will show the value 10 and 17. Any help is appreciated.

#!/usr/bin/sh;
cntr=1;
while read myline
do
cntr=`expr $cntr + 1`;
if [ `echo $myline | egrep '[a-z]'` ]; then
echo $cntr;
fi
done < txt

Here i am matching for the lines which contains a-z . Alter ur script accordingly

Cheers

in that case try

 
 awk '$0 ~ /anycharacter/{print "line no : "NR}' filename

Please don't hijack threads - start your own.