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 -r /node$
node is at the start of the file name. The
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, etc), add
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.