reg exp
^ (caret) = match expression at the start of the line, as in ^A
$ (question) = match expression at the end of the line , as in A$
\ (blash slash) = turn off the special meaning of the text, as in \^
[ ] (bracket) = match any one of the enclosed character, as in [aeiou] use hyphen for range as in [0-9]
[^] = match any one character expect those enclosed in [] , as in [^0-9 ]
. (Period) = match a single character of the any value, expect end of line.
* (asterisk) = match zero or more of the preceding character or expression.
\{x, y\} = match x and y occurrence the preceding
\ { x\} = match exactly x occurrence of the preceding
\{x, \} = match x or morecl occurrence of the preceding.
grep shravan file {search files for line with shravan}
grep '^shra' file {'shra' at the start of the line}
grep 'shra$ ' file {'shra' at the end of the line}
grep '^shra$' file {line Containing only shra}
grep '^\^ s' file { line starting with ^s, \ escape the ^}
Grep '[Ss]hra' file { search for shra or Shra}
Grep '[Dd][Oo]g' {search for Dog, dog, DOg, dOg}
Grep '^$' file { search for blank lines}
Grep '[0-9][0-9] ' file {search for pair of numertic digital}
Comments
Post a Comment