8. Shell正则表达式

The Unix shell recognises a limited form of regular expressions used with filename substitution:

Operators
Operator Effect
? The hook operator specifies any single character.
[ ] boxes enable a single character to be matched against a character lists or character range.
[! ] A compliment box enables a single character not within in a character list or character range to be matched.
* An asterisk specifies zero or more characters to match.

Some operators behave differently in the shell: The asterisk and hook operators do not not need to follow a previous character in the shell and they exhibit non traditional regular expression behaviour.

Unsupported Constructs: Within the shell, a compliment box is formed using the pling symbol. The shell does not support the use of a careted box for character list exclusion. In the shell, a caret symbol within a box will simply be treated as one of the characters within the character list for matching.

Use in Tools

Tools and languages that utilize this regular expression syntax include:

  • Bourne compatible shells

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注