how can i use regex with locate command in linux

linux, regex

Solution

To use globbing characters in your query you shouldn't specify regex (as you do with `-r` option), so just do:

locate "/usr/*pip"

From the man page:

If --regex is not specified, PATTERNs can contain globbing characters. If any PATTERN contains no globbing characters, locate behaves as if the pattern were *PATTERN*.

Problem

I want to use the locate command with regex but i am not able to use it. I want to find `pip` file which is in /usr folder. i am trying this `locate -r "/usr/*pip"`

Original source