Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

want to find all lines with the next office id.

Status
Not open for further replies.

ronaldsiebes

Technical User
Jun 27, 2006
3
NL
From these lines I want to place all lines with the office id 1002 and 1102 in an new file. The office id start at character 22.

The next office id. 100200908273292s This is the end of line one.
The next office id. 102200908273292s This is the end of line two.
The next office id. 110200908273292s This is the end of line three.
The next office id. 101200908273292s This is the end of line four.
The next office id. 102200908273292s This is the end of line five.
The next office id. 110200908273292s This is the end of line six.
 
And what have you tried so far ?
You may consider grep or sed or awk or ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well I first did
grep -E '1102|1002' filename > newfilename

This work fine. But if the lines are like this, then my problem start. In line two the numbers 1102 is named, but this is not in the position I need to check. So with the grep it won't work.

The next office id is 1022. 100200908273292s This is the end of line one.
The next office id is 1102. 102200908273292s This is the end of line two.
The next office id is 1012. 110200908273292s This is the end of line three.
The next office id is 1022. 101200908273292s This is the end of line four.
The next office id 1102. 102200908273292s This is the end of line five.
The next office idis 1002. 110200908273292s This is the end of line six.
 
The office id start at character 22
grep -E '^.....................(1102|1002)' filename > newfilename

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This works fine on my linux server. So I do think that it will also work on AIX.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top