split a file at a specified string

to find log files modification, i want to select all the lines of a file behind a string (found by grep ?).
:rolleyes:

To select all lines from beginning of the file up to but not including a specific line:

awk '{if (match($0,"string")) exit; print}' myfile

If you want all lines up to and including the specific line:

awk '{print; if (match($0,"string")) exit}' myfile

Identification of the termination line is being done by looking for "string" in the entire line, but this can be whatever you need, such as checking the nth word on the line etc.

If you want to select groups of lines beginning with a line that contains "start" and through a line that contains "end":

awk '/start/,/end/' myfile

That would also get a partial group of lines, starting with a line that contains "start" and terminating with end-of-file.

In the last sentence,
awk '/start/,/end/' myfile select from /start/ to /end/, what can i write for :

from /start/ to the end of file ?
Thanks

That is a little different. There are different approaches. One way is to set a flag on that will then test true for remainder of file processing:

awk '/string/ {p=1}; p==1 {print}' myfile

Or if you want to select lines starting with the line AFTER the found line:

awk '/string/ {p=1;next}; p==1 {print}' myfile

Or, using the /from/,/to/ construct, you could use a to-string that you know would never be in the file, such as:

awk '/string/,/ue4R6TbWQ2Jk/' myfile

That would select lines beginning with a line containing "string" through a line containing ue4R6TbWQ2Jk or end-of-file, whichever is encountered first.

Thank's a lot to help me

can i have a pipe in my search string ?

Yes. The awk program is in single quotes, thus some protection from the shell. I just tested a search string that contains an embedded pipe character, and it worked without having to precede with backslash or anything.