I currently using grep til find files which has some relations to ax.

The way i am currently searching is by

grep -ril "ax" .

But this also finds files with ax as a substring like words such as max, axis and so on.

How do i ensure the the word I am looking for only have ax in it .. and isn't a substring of some sort?

  • You will need to define exactly how the word should "have ax in it" yet not have "ax as a substring" Mar 31, 2018 at 1:46
  • Can you please put an example of what input you have and the output you're expecting?
    – tachomi
    Mar 31, 2018 at 3:15

2 Answers 2


You can use -w option in grep to find the same.

 grep -w 'ax' *



above command will search exactly for the word "ax" in path then it prints the filename and string searched for.

If you need line number with filename you can use below command

 grep -win 'ax' *


In this example, simply adding spaces before and after "ax" ought to do the trick.

grep -irl " ax " *

Is that what you're looking for?

  • well.. Not quite... I could also be Axconfig Mar 30, 2018 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .