Searching a large file in UNIX using a program.

How can I search a large file for a pattern, the result should be a pointer to the line containing the pattern.
I have to do this in a program that is also writing to that file.
The file will be in on a UNIX platform.

Hi,

If you need to perform the pattern search and the file interaction from the program itself, I’d suggest you to use Python or Java where you can compile regular expressions.

Once you know how the patern looks like, either read the file line by line detecting the line where the pattern occurs, or, in case the pattern is “broken” between several lines, estimate the length of each line (or even better) make it a fixed one and just get the whole file as a big string and perform the pattern matching then!

Best,

Bruno

I cannot read the file line by line as it is a part of a large corpus, no the pattern is not broken, it is an organised phrasal output.