QuestionQ52

VerifiedBasic Unix Skills

Consider this file, legalfile:

disclosure  
non-disclosure  
non disclosure  

Which line or lines does the following command match? Note the space after the dash inside the brackets.

grep "non[- ]disclosure" legalfile  
Explanation

A bracket expression matches one character from its listed set. In [- ], the leading hyphen is literal and the other listed character is a space, so the expression matches both non-disclosure and non disclosure.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!