grep a string at specific position

Dell Dell optiplex 755 desktop desktop c...
April 14, 2011 at 12:49:53
Specs: Windows 7 64 bit, AMD Athlon, 6GB
Hi,

I have a text file which contains thousands of record and each record has a length of 256 characters.

I need to grep for the lines containing the text 401055, starting at column 9.

How do I achieve this with grep or egrep command? I don't want a shell script or awk to achieve this.

Thanks,
Balaji.


See More: grep a string at specific position

Report •

#1
April 14, 2011 at 13:40:09
Do you know what grep stands for - Global Regular Expression Print. It means display all the text in the file that matches this pattern. If you don't allow the shell or a Unix tool to limit the search, then you are out of luck and you have to live with the global return.

Of course, I could be wrong.


Report •

#2
April 14, 2011 at 13:49:13
Thanks for the reply.

It can display all text in a line provided the line contains the text 401055 at column 9.

The below command used to work before, but not working now (I guess it is after some OS upgrade). I am using AIX 5.3

egrep '^.8{401055}' filename.

Thanks,
Balaji.


Report •
Related Solutions


Ask Question