ignorecase in AWK
The following command is working as expected.
# some command | awk '/(\<^create\>|\<^alter\>|\<^drop\>)/,/;/'
create table todel1 (id int) max_rows=2
/*!*/;
alter table todel1 engine=InnoDB
/*!*/;
create database common
/*!*/;
create database rules
/*!*/;
But it matches only the lower case "create", "alter" etc. I want to use IGNORECASE switch in the awk statement so that it will return all instances of the search term.
Add IGNORECASE = 1;
to the beginning of your awk command like so:
bash-3.2$ echo "Create" | awk '/^create/;'
bash-3.2$ echo "Create" | awk 'IGNORECASE = 1;/^create/;'
Create
The following line executes an OR test instead of an AND :
echo -e "Create\nAny text" | awk 'IGNORECASE = 1;/^create/;'
Create
Create
Any text
The BEGIN special word solved the problem :
echo -e "Create\nAny text" | awk 'BEGIN{IGNORECASE = 1}/^create/;'
Create
Hope this helps.
Sebastien.