Regular Expression:
[.] DOT | dot matches for a single character |
[abcd] | matches one of the list ,say [abcd] matches one of a,b,c,d |
[a-d] | matches the range of characters a to d |
[^a-i] | should not contain the range a to i |
[a*] ~= {0,} | match zero or more a’s |
[a+] ~= {1,} | match one or more a’s |
[a?] ~= {0,1} | zero or one occurance of letter a |
wh(at|en|ere} | what when where , you can specify group of letters and also a pipe to mark OR operator |
^not | start with string not,notify,notice etc…… |
not$ | end with not like knot |
GREP: search Globally for Regular Expression and Print
grep | option[s] |
-n number in the file | |
-c count the number of occurrences, unlike wc –l it gives the file wise count | |
-A context selection After -B Context selection Before you can specify number with A or B | |
-l List the names of files | |
-r recursively Grep | |
-s , if there are permission errors it suppresses | |
-e used to search multiple regular expressions |
Egrep: Extended GREP { More operators +,?,(),|}
Fgrep: Fixed length Grep , does not support operators
No comments:
Post a Comment