ignorecase in AWK

后端 未结 4 816
轮回少年
轮回少年 2020-12-03 07:32

The following command is working as expected.

# some command | awk \'/(\\<^create\\>|\\<^alter\\>|\\<^drop\\>)/,/;/\' 
create table todel1         


        
4条回答
  •  广开言路
    2020-12-03 07:35

    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.

提交回复
热议问题