开发者

Selecting Update queries alone from list of files using shell script

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][A开发者_JS百科a][Tt][Ee] .*[sS][eE][tT]/{ gsub(/.*UPDATE/,"UPDATE");gsub(/.*Update/,"Update");gsub(/.*update/,"update");gsub(/\n+/,"");print file,"#",$0;}  
  ' "$TEST"  >> $OUT


This seems more readable to me without all the [Uu] and it doesn't require grep:

{ line=tolower($0); if (line ~ /update .*set/ && line !~ /updated|updatesql/) { gsub ...


you can try using grep first, (and i assume you are on Solaris.)

grep -i "update.*set" "$TEST" | egrep -vi "updatesql|updated" | nawk .....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜