awk help

Hi Guys,

I've to print a block of lines that starts with a keyword CREATE and ends with ; using awk command is there a way to do this?

awk '{if ($1=="CREATE" ) {print $0}}' filename. 

This will print only the line that has CREATE but I want to search multiple lines and if there is a ";" in any of line it should print all the lines from CREATE till ;

Any thoughts please?

---------- Post updated at 05:45 PM ---------- Previous update was at 05:30 PM ----------

The below statement is working :slight_smile:

cat filename | awk '/CREATE/,/;/'

not a big deal but the use of cat is not needed.

use this instead

awk '/CREATE/,/;/' filename