Dell 6.2 Server User Manual


 
Operator Description Sample Result
. Match any one character. grep.ord sample.txt Matches
ford
,
lord
,
2ord
, etc. in the
file sample.txt.
[] Match any one character listed
between the brackets
grep [cng]ord sample.txt Matches only
cord
,
nord
, and
gord
[^] Match any one character not listed
between the brackets
grep [^cn]ord sample.txt Matches
lord
,
2ord
, etc., but not
cord
or
nord
grep [a-zA-Z]ord sample.txt Matches
aord
,
bord
,
Aord
,
Bord
, etc.
grep [^0-9]ord sample.txt Matches
Aord
,
aord
, etc., but not
2ord
, etc.
Table 350:
Character-matching operators in regular expressions
Regular Expression Repetition Operators
Repetition operators are
quantifiers
that describe how many times to search for a specified string. Use them in
conjunction with the character-matching operators in Table 351 to search for multiple characters.
Operator Description Sample Result
? Match any character one time if
it exists
egrep “?erd” sample text Matches
berd
,
herd
, etc.,
erd
* Match declared element multiple
times if it exists
egrep “n.*rd” sample.txt Matches
nerd
,
nrd
,
neard
, etc.
+ Match declared element one or
more times
egrep “[n]+erd” sample.txt Matches
nerd
,
nnerd
, etc., but not
erd
{n} Match declared element exactly
n
times
egrep “[a-z]{2}erd” sample.txt Matches
cherd
,
blerd
, etc., but not
nerd
,
erd
,
buzzerd
, etc.
{n,} Match declared element at least
n
times
egrep “.{2,}erd” sample.txt Matches
cherd
and
buzzerd
, but not
nerd
{n,N} Match declared element at least
n
times, but not more than
N
times
egrep “n[e]{1,2}rd” sample.txt Matches
nerd
and
neerd
Table 351:
Regular expression repetition operators
Regular Expression Anchors
Anchors describe where to match the pattern, and are a handy tool for searching for common string combinations.
Some of the anchor examples use the vi line editor command
:s
, which stands for
substitute
. That command uses the
syntax: s/pattern_to_match/pattern_to_substitute.
DellPowerConnectW-SeriesArubaOS6.2 | User Guide ExternalServicesInterface | 772