Skip to content
Advertisement

how can i use regex with locate command in linux

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"

Advertisement

Answer

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*.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement