Print the complete line based on position as input

Hi ,

I have a text file like below

abcd2223232321212121324343
asdsfffhfgfgfhgfhghghghghghgh
dfdfdfgfghfgfgfgfgfgghghghghgh
dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf
1234567890sasasasfdfbffghffhf
abcd222323232121212abcdsds

in the above file i need to grep and print the lines if 14th to 18th character = 1212

The output should be the complete line like below

Output :

abcd2223232321212121324343
abcd222323232121212abcdsds

some one please help

What have you tried so far?

I tried the following

cut -b14-18 input > input1
egrep -finput1 input > output.

In this i am getting all the lines that contain the character 1212 also.

Try:

awk 'substr($0,14,4)==1212' file

Thanks man it worked awesome :slight_smile: and nawk also worked out