When using grep, it will highlight any text in a line with a match to your regular expression.
What if I want this behaviour, but have grep print out all lines as well? I came up empty after a quick look through the grep man page.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use ack. Check out its
--passthruoption here: ack. It has the added benefit of allowing full Perl regular expressions.You can also do it using grep like this:
This will match all lines and highlight the patterns. The
^matches every start of the line but won’t get printed/highlighted since it’s not a character.(Note that most of the setups will use –color by default. You may not need that flag).