0

I have a input:

 achil           1   234671.82694245825        234671.82694245825       0.43995134290095084     
 achil           2   234671.82694245825        234671.82694245825       0.43995134290095084     
o 0  1 0 1 1      5.732820000     0.000 = PERIOD(0)
4
5
6
1
2

I would like to print from line with o 0 1 0 1 1 5.732820000 0.000 = PERIOD(0) to end of the file.

Desired output:

o 0  1 0 1 1      5.732820000     0.000 = PERIOD(0)
4
5
6
1
2

I tried:

awk '/o 0\s+1 0 1 1\s+5.732820000\s+0.000 = PERIOD(0)/,/*/' input > output

and the output is an empty file. What is wrong please?

2 Answers2

2

Try the following:

awk '/o 0  1 0 1 1/,0' input 

Consider this one liner awk /pattern1/,/pattern2/' input. It matches all the lines starting with a line that matches "pattern1" and continuing until a line matches "pattern2" (inclusive).

In this one-liner "pattern1" is "o 0 1 0 1 1" and "pattern2" is just 0 (false). So this one-liner prints all lines starting from a line that matches "o 0 1 0 1 1" continuing to end-of-file (because 0 is always false, and "pattern2" never matches)

Reference

j23
  • 3,139
  • 1
  • 6
  • 13
2

This may also do:

awk '/o 0  1 0 1 1/ {f=1} f' file
o 0  1 0 1 1      5.732820000     0.000 = PERIOD(0)
4
5
6
1
2

When pattern is found, set flag f to true.
When flag f is true, do default action, print

Jotne
  • 40,548
  • 12
  • 51
  • 55