grep -Ir --exclude="*\.svn*" "pattern" *
note that the grep path is the full path, not just the file names!
Showing posts with label grep. Show all posts
Showing posts with label grep. Show all posts
Wednesday, July 28, 2010
grep excludes files, directories
grep regular exp.
Special Characters
Here, we outline the special characters for grep. Note that in egrep (which uses extended regular expressions), which actually are no more functional than standard regular expressions if you use GNU grep ) , the list of special characters increases ( | in grep is the same as \| egrep and vice versa, there are also other differences. Check the man page for details ) The following characters are considered special and need to be "escaped":
Square brackets behave a little differently. The rules for square brackets go as follows:
A regular expression may be followed by one of several repetition operators:
? The preceding item is optional and matched at most once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{n} The preceding item is matched exactly n times.
{n,} The preceding item is matched n or more times.
{n,m} The preceding item is matched at least n times, but not more than m times.
In basic regular expressions the metacharacters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions
\?, \+, \{, \|, \(, and \).
Here, we outline the special characters for grep. Note that in egrep (which uses extended regular expressions), which actually are no more functional than standard regular expressions if you use GNU grep ) , the list of special characters increases ( | in grep is the same as \| egrep and vice versa, there are also other differences. Check the man page for details ) The following characters are considered special and need to be "escaped":
Note that a $ sign loses its meaning if characters follow it (I think) and the carat ^ loses its meaning if other characters precede it.? \ . [ ] ^ $
Square brackets behave a little differently. The rules for square brackets go as follows:
- A closing square bracket loses its special meaning if placed first in a list. for example
[]12]matches ] , 1, or 2. - A dash - loses it's usual meaning inside lists if it is placed last.
- A carat ^ loses it's special meaning if it is not placed first
- Most special characters lose their meaning inside square brackets
- * if at the beginning of the regular exps, lose its meaning.
A regular expression may be followed by one of several repetition operators:
? The preceding item is optional and matched at most once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{n} The preceding item is matched exactly n times.
{n,} The preceding item is matched n or more times.
{n,m} The preceding item is matched at least n times, but not more than m times.
In basic regular expressions the metacharacters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions
\?, \+, \{, \|, \(, and \).
Subscribe to:
Posts (Atom)