Linux locate command search multiple strings

Discussion in 'General Linux' started by Sonal, Aug 22, 2012.

  1. Sonal

    Sonal New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
  2. MrBojangles7331

    MrBojangles7331 New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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.

Share This Page