Regular Expressions   «Prev 

Using ., *, and [ ] in Regular Expressions

1) In this command, the regular expression matches a pattern of five characters, the "s.tte"
The dot (.) means any character can occur in the second position.

1) The * matches zero or more characters preceding it.
Hence, this regular expression finds patterns that do not necessarily begin with the letter "s".

2) By adding the dot(.), this expression will match the letter s, followed by zero or more characters, followed by zzle.
This time, only two lines match, sizzle and swizzle.

3) This expression uses [] to match a character range, uppercase A to H. The full expression matches all lines that contain VA, VB, VC, and so on through VH, anywhere in the line.

4) Without quotes, the [] is expanded by the shell, resulting in arguments VA, VB, VC, and so on. The first agrument, VA, is treated as a pattern, but the remaining ones are treated as file names.