combine multiple awk commands

awk

Solution

You can do:

awk '/^Col1 /,/^$/{ if( $2 == "bar" && $3 > 1 ) print $1}' example

Problem

Assuming the following input: ``` $ cat example {many lines of text} Col1 Col2 Col3 foo bar 2 bar baz 3 baz bar 8 bar foo 0 foo baz 9 baz bar 3 {many more lines of text} ``` The following two awk snippets parse out the data I'm after: ``` cat example | awk -v 'RS=\n\n' '/^Col1 /' | awk '$2 == "bar" && $3 > 1 {print $1}' foo baz baz ``` How do I combine the two snippets into a single bit of awk, e.g. ``` awk ' ... ... ... ' example ```

Original source