check position of end of line(URGENT PLS)

I Have to check in a file that all the lines are ending at same posiotin.

Ex : line 1 is ending at position 88
line 2 should at same position i.e 88

Thanks in advance

shouldbe=88
awk -v e=$shouldbe '{ if(length($0) != e){print "bad line ", NR} ' filename

Use nawk or /usr/xpg4/bin/awk on Solaris:

awk 'FNR==1{len=length;next}
length!=len{printf "Check file %s,record %d\n",FILENAME,FNR}' filename

P.S. For portability use length($0).

Have to check in a file that the lines starting with 620 and 705
are ending at same posiotin.

82012345
62023232323
70523949558
62023255454
9999

In the above lines, i have to check the lines starting with 620 and 705 are having the length 94.

Can anyone help. Immediate response is very much appriciated.

Use the command given above but change the awk to only look at the relevant lines by doing the following:
awk -v e=$shouldbe '{ /^(620|705)/ if(length($0) != e){print "bad line ", NR} ' filename

Should work

Thankyou very much for your immediate response.

But its giving some syntax error.

this is what i used.

shouldbe=94
srcFile=$1

awk -v e=$shouldbe '{ /^(620|705)/ if(length($0) != e){print "bad line ", NR} }' $srcFile

The error is below

syntax error The source line is 1.
The error context is
{ /^(620|705)/ >>> if <<< (length($0) != e){print "bad line ", NR} }
awk: The statement cannot be correctly parsed.
The source line is 1.

Can you please correct it?

Looks like this was answered for you in another thread: