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
 


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.
 

Staff online

Members online


Latest posts

Top