Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep question

Status
Not open for further replies.

abacus

Civil/Environmental
Apr 15, 2002
1
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...
 
Replies continue below

Recommended for you

hpux

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor