For example:
man perl | grep '-w'
only to receive error messages
Use the double hyphen:
% man perl | grep -- '-w' The "use warnings" pragma produces some lovely diagnostics. One can also use the -w flag, but its use is normally discouraged, because it gets applied to all executed Perl code, This usage of -- is recommended by the POSIX standard:
The first
--argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the-character.
Use -- to give a parameter which starts with - .
MacBook-Pro:~ chen$ man perl | grep -- '-w' also use the -w flag, but its use is normally discouraged, because it MacBook-Pro:~ chen$ In most bash builtin & some other commands, the -- means the end of options. By the same token, you can delete a file which name is -f.txt using this command:
MacBook-Pro:tmp chen$ rm -fv -- -f.txt -f.txt MacBook-Pro:tmp chen$
man perl | grep -- '-w'