The difference between regular expressions and shell patterns is in how some characters are interpreted.
Let's consider a star character (*). In shell pattern it is interpreted as match of zero or more characters. In regular expression is interpreted differently: it matches preceding character or group zero or more times.
For example, the string '*tmp' will match all strings ending with tmp by shell pattern processor, but regular expression processor won't match anything at all! In order to write an equivalent regular expression of a shell pattern we have to write '.*tmp'.
These commands are equivalent:
find . -name '*tmp'
find . -regex '.*tmp'
So be careful when writing matching expressions and know how it is interpreted.
No comments:
Post a Comment