FreeBSD 9: How to locate an exact filename?

If you look at locate --help, you may find:

  -r, --regexp REGEXP    search for basic regexp REGEXP instead of patterns
      --regex            patterns are extended regexps

You can use -r to provide a regexp pattern to locate:

locate -r /node$

The / ensures node is at the start of the file name. The $ ensures node is at the end of the file name. This will give you only the files matching the exact file name.

If you want to do a case-insensitive search (matches Node, NODE, nOdE, etc), add -i:

locate -i -r /node$

If locate does not support regexp, you can use grep (as mentioned by Iracicot):

locate node | grep /node$
locate -i node | grep -i /node$

You may use grep with locate

server2# locate node | grep node$

The $ sign will tell grep to look at the end of the string.