A little extended problem from cat line x to line y on a huge file:I have a huge file (2-3 GB). I'd like to cat/print only from the line having foo: to the line having goo:. Assume that foo: and goo: only appear once in a file; foo: proceeds goo:.So far this is my approach:First, find the line with foo: and goo:: grep -nr foo: bigfileReturns 123456: foo: hello world! and 654321: goo: good bye!Once I know these starting and ending line numbers, and the difference (654321-123456=530865) I can do selective cat:tail -n+123456 bigfile | head -n 530865My question is that how can I effectively substitute the line number constants with expressions (e.g., grep ...)?I can write a simple Python script but want to achieve it using only combining commands.
Only cat from specific line X (with a pattern) to other specific line Y (with a pattern)
sed;awk;grep;tail;head