Linux locate command search multiple strings

S

Sonal

Guest
Please let me know how to search multiple strings in filename through locate command:

locate -b AJAY

returns all files which contains AJAY in filename.

Now I want files which contains both AJAY and ARR. If I use the below command it takes minutes to execute when I have millions of records to search from

locate -b "*AJAY*ARR*"

Please let me know how to speed up the process
 


OP
M

MrBojangles7331

Guest
Well, just a quick-and-dirty solution could be

locate -b AJAY | grep ARR

I believe however, a more proper solution would be using the -r flag for locate, which allows you to use POSIX regular expressions.
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Staff online

Members online


Top