[root@localhost opt]# cat cfgkey = value[root@localhost opt]# grep 'key\s*=\s*.+' cfg[root@localhost opt]# My intent is: the = sign may be followed by zero or more spaces, but must be followed one or more non-space characters.Why doesn't it output the line key = value?
Why doesn't regex '.+' work as expected?
grep;regular expression
Observe:$ grep 'key\s*=\s*.+' cfg$ grep 'key\s*=\s*.\+' cfgkey = value$ grep -E 'key\s*=\s*.+' cfgkey = valueIn Basic Regular Expressions (BRE, the default), + means a plus sign.  As a GNU extension, one can signal one-or-more-of-the-previous-character using \+.  This is also true of ?, {, |, and (.  Unless escaped with a backslash, these are all treated a ordinary characters under BRE.The rules change if you use Extended Regular Expressions, -E.  For ERE, the backslash isn't needed and a plain + means one-or-more-of-the-previous-character.  Under ERE, \+ means a plain normal plus sign.