Metacharacter | Meaning |
^ | The ^ (circumflex or caret) inside square brackets negates the expression (we will see an alternate use for the circumflex/caret outside square brackets later), for example, [^Ff] means anything except upper or lower case F and [^a-z] means everything except lower case a to z. Notes:
|
jtony@genoa:~/learn/shell/UserGuide$ cat string1.txt
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
Mozilla/4.75 [en](X11;U;Linux2.2.16-22 i586)
jtony@genoa:~/learn/shell/UserGuide$ cat string2.txt
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
Mozilla/4.75 [en](X11;U;Linux2.2.16-22 i586)
jtony@genoa:~/learn/shell/UserGuide$ grep -rn '[^A-M]in' string1.txt
1:Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
jtony@genoa:~/learn/shell/UserGuide$ grep -rn '[A-Za-z]in' string1.txt
1:Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
2:Mozilla/4.75 [en](X11;U;Linux2.2.16-22 i586)
This series refer the online article:
http://www.zytrax.com/tech/web/regex.htm#search
No comments:
Post a Comment