1 |
On Mon, 2 Mar 2009 13:01:31 +1100 |
2 |
Adam Carter <Adam.Carter@×××××××××.au> wrote: |
3 |
|
4 |
> I need to select all the lines between string1 and string2 in a file. String1 exists on an entire line by itself and string2 will be at the start of a line. What's the syntax? I cant use -A as there is a variable number of lines. |
5 |
|
6 |
I doubt there's a solution involving grep, unless you use it twice in |
7 |
the same pipe: |
8 |
grep -A9999 string1 /some/file | grep -B 9999 string2 |
9 |
|
10 |
But there can be any amount of more elegant solutions, involving |
11 |
sed: |
12 |
sed -n '/string1/,/string2/p' /some/file |
13 |
|
14 |
-- |
15 |
Mike Kazantsev // fraggod.net |