2

Running locate command with a file name returns multiple entries as,

a.py
a.pyc
a.py~

Obviously, i am not looking for binaries/compiled files. I tried to configure locate command to ignore files that has pattern *.pyc, *.py~. Man page shows, locate command doesn't have globbing option.

How can one configure locate command to ignore files that match a pattern?

3
  • I am confused, since when did python scripts become binaries/compiled files?
    – jas-
    Commented May 11, 2015 at 3:11
  • when i said binaries/compiled files, i meant .pyc files and not .py scripts
    – user93868
    Commented May 11, 2015 at 3:13
  • 1
    There are several implementations of locate and they have different capabilities. Which one are you using? (e.g. GNU locate, mlocate, …) Commented May 11, 2015 at 21:14

1 Answer 1

-1

Using \ disables globbing and forces a literal pattern match, as mentioned in the manpages:

To search for a file named exactly NAME (not *NAME*), use

locate -b '\NAME'

Because \ is a globbing character, this disables the implicit replacement of NAME by *NAME*.

You must log in to answer this question.