grep question
grep question
(OP)
I am trying to use the grep command to search for lines that contain a particular string at a certain character position. Is there any way to tell grep to only search for the string at a specified position of each line?
Example-
00001JIM SMITH 35LL
00002MIKE JONES 30LL
00003STEVE SIMMS 02LL
Let's say I only want to return lines that contain '02' at the 20th character position.
Thanks in advance...
Example-
00001JIM SMITH 35LL
00002MIKE JONES 30LL
00003STEVE SIMMS 02LL
Let's say I only want to return lines that contain '02' at the 20th character position.
Thanks in advance...





RE: grep question
RE is a regular expression
RERE is a regular expression made from two reg exps
. is any character except newline
RE /{m/} is exactly m repetitions of RE
so
grep -e ^./{20/}20 filename
gets you start of line, 20 characters and a 20 in the line.
good luck, you might have to modify the code slightly for your O/S.
Lynn