Selecting Update queries alone from list of files using shell script
Posted
by Harish
on Stack Overflow
See other posts from Stack Overflow
or by Harish
Published on 2010-04-08T07:59:14Z
Indexed on
2010/04/08
8:03 UTC
Read the original article
Hit count: 327
shell
I am trying to get Update queries from a list of files using this script.I need to take lines containing "Update" alone and not "Updated" or "UpdateSQL"As we know all update queries contain set I am using that as well.But I need to remove cases like Updated and UpdatedSQL can anyone help?
nawk -v file="$TEST" 'BEGIN{RS=";"}
/[Uu][Pp][Dd][Aa][Tt][Ee] .*[sS][eE][tT]/{ gsub(/.*UPDATE/,"UPDATE");gsub(/.*Update/,"Update");gsub(/.*update/,"update");gsub(/\n+/,"");print file,"#",$0;}
' "$TEST" >> $OUT
© Stack Overflow or respective owner