0

I was trying to find files in sub-directory that that has a substring and print the files and the lines. But my command only catch files that contains the whole word. Could you please let me know why and correct me?

For example, some my files contain the "my_isr" word.

  1. Working command (print files and lines): grep -rnw . -e "my_isr"

  2. Non-working command (no matched files): grep -rnw . -e "isr"

1 Answer 1

1

The -w flag in your commands causes your version of grep to only match whole words; dropping that will match on arbitrary substrings:

grep -rn . -e isr

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.