• Re: mdfind vs ag (was Re: =?UTF-8?B?4oCcNQ==?= MacOS command line tools I swear by over their GUI =?UTF-8?B?Y291bnRlcnBhcnRz4oCd?=

    From rbowman@bowman@montana.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Thu May 7 01:34:15 2026
    From Newsgroup: comp.sys.mac.advocacy

    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Wed May 6 19:31:12 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From John Bokma@contact@johnbokma.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Thu May 7 12:08:28 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line
    the word 'cat' is found on and the 3 lines before this line and 2 after?



    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.
    --
    Static tumblelog generator: https://github.com/john-bokma/tumblelog/
    Available as Python or Perl. Example tumblelog: https://plurrrr.com/
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Thu May 7 07:27:48 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line
    the word 'cat' is found on and the 3 lines before this line and 2 after? >>>


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.


    Given that the tools exist to "remember" for you, that hardly matters,
    and I guarantee you that mdfind is orders of magnitude faster.

    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Fri May 8 13:44:21 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D
    --
    Main's Law:
    For every action there is an equal and opposite government program.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Fri May 8 13:52:29 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line
    the word 'cat' is found on and the 3 lines before this line and 2 after? >>>
    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.

    Given that the tools exist to "remember" for you, that hardly matters,
    and I guarantee you that mdfind is orders of magnitude faster.

    Sounds a bit like UNIX locate/plocate.
    --
    If a train station is a place where a train stops, what's a workstation?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Fri May 8 11:33:59 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-08 10:44, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D
    Nope.

    Indexed.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Fri May 8 11:38:41 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-08 10:52, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line
    the word 'cat' is found on and the 3 lines before this line and 2 after? >>>>
    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.

    Given that the tools exist to "remember" for you, that hardly matters,
    and I guarantee you that mdfind is orders of magnitude faster.

    Sounds a bit like UNIX locate/plocate.
    You need to learn a little more about how Apple implemented what in the
    GUI part of the OS is called "Spotlight".

    "mdfind" is just a command line tool that leverages the same index that
    is created for Spotlight.

    I just ran this:

    agbaker@Alans-M3 / % time mdfind ahlstrom

    The result:

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading keywords and predicates for locale "en_CA"

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading keywords and predicates for locale "en"

    /Users/agbaker/Library/Group
    Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/Messages/109/6DCA995E-E984-4A01-8FEA-ECF490248F0B.olk15Message

    mdfind ahlstrom 0.04s user 0.06s system 38% cpu 0.259 total
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sat May 9 08:59:21 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:44, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D

    Nope.

    Indexed.

    And cached.
    --
    poisoned coffee, n.:
    Grounds for divorce.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sat May 9 09:06:32 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:52, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line >>>>>> the word 'cat' is found on and the 3 lines before this line and 2 after? >>>>>
    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.

    Given that the tools exist to "remember" for you, that hardly matters,
    and I guarantee you that mdfind is orders of magnitude faster.

    Sounds a bit like UNIX locate/plocate.

    You need to learn a little more about how Apple implemented what in the
    GUI part of the OS is called "Spotlight".

    "mdfind" is just a command line tool that leverages the same index that
    is created for Spotlight.

    Duh-uh. I found that out on my own.

    I just ran this:

    agbaker@Alans-M3 / % time mdfind ahlstrom

    The result:

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading keywords and predicates for locale "en_CA"

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading keywords and predicates for locale "en"

    /Users/agbaker/Library/Group
    Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/Messages/109/6DCA995E-E984-4A01-8FEA-ECF490248F0B.olk15Message

    mdfind ahlstrom 0.04s user 0.06s system 38% cpu 0.259 total

    Whoop de do.

    $ time locate ahlstrom &> /dev/null
    real 0m1.027s
    user 0m0.927s
    sys 0m0.141s

    This is on my computer, and emits 442650 hits (as counted by
    piping the command to wc -l.)

    Another example, a more realistic use of locate:

    $ time locate vim
    real 0m0.043s
    user 0m0.015s
    sys 0m0.023s
    --
    Laundry is the fifth dimension!! ... um ... um ... th' washing machine
    is a black hole and the pink socks are bus drivers who just fell in!!
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sat May 9 06:09:56 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-09 05:59, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:44, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D

    Nope.

    Indexed.

    And cached.


    Nope.

    Yes, there is an index.

    No, nothing was cached.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sat May 9 06:10:44 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-09 06:06, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:52, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line >>>>>>> the word 'cat' is found on and the 3 lines before this line and 2 after?

    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.

    Given that the tools exist to "remember" for you, that hardly matters, >>>> and I guarantee you that mdfind is orders of magnitude faster.

    Sounds a bit like UNIX locate/plocate.

    You need to learn a little more about how Apple implemented what in the
    GUI part of the OS is called "Spotlight".

    "mdfind" is just a command line tool that leverages the same index that
    is created for Spotlight.

    Duh-uh. I found that out on my own.

    I just ran this:

    agbaker@Alans-M3 / % time mdfind ahlstrom

    The result:

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading
    keywords and predicates for locale "en_CA"

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading
    keywords and predicates for locale "en"

    /Users/agbaker/Library/Group
    Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main
    Profile/Data/Messages/109/6DCA995E-E984-4A01-8FEA-ECF490248F0B.olk15Message >>
    mdfind ahlstrom 0.04s user 0.06s system 38% cpu 0.259 total

    Whoop de do.

    $ time locate ahlstrom &> /dev/null
    real 0m1.027s
    user 0m0.927s
    sys 0m0.141s

    This is on my computer, and emits 442650 hits (as counted by
    piping the command to wc -l.)

    Another example, a more realistic use of locate:

    $ time locate vim
    real 0m0.043s
    user 0m0.015s
    sys 0m0.023s


    "locate" doesn't locate everything.

    "mdfind" and the system it uses indexing everything.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sun May 10 08:06:18 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    On 2026-05-09 05:59, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:44, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D

    Nope.

    Indexed.

    And cached.

    Nope.

    Yes, there is an index.

    No, nothing was cached.

    Are you saying that MacOS does not cache data? Data such as... an
    index?

    Surely you're joking, Mr. Fine Man!
    --
    Innocence ends when one is stripped of the delusion that one likes oneself.
    -- Joan Didion, "On Self Respect"
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sun May 10 08:16:39 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    On 2026-05-09 06:06, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:52, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line >>>>>>>> the word 'cat' is found on and the 3 lines before this line and 2 after?

    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.

    Given that the tools exist to "remember" for you, that hardly matters, >>>>> and I guarantee you that mdfind is orders of magnitude faster.

    Sounds a bit like UNIX locate/plocate.

    You need to learn a little more about how Apple implemented what in the
    GUI part of the OS is called "Spotlight".

    "mdfind" is just a command line tool that leverages the same index that
    is created for Spotlight.

    Duh-uh. I found that out on my own.

    I just ran this:

    agbaker@Alans-M3 / % time mdfind ahlstrom

    The result:

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading
    keywords and predicates for locale "en_CA"

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading
    keywords and predicates for locale "en"

    /Users/agbaker/Library/Group
    Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main
    Profile/Data/Messages/109/6DCA995E-E984-4A01-8FEA-ECF490248F0B.olk15Message >>>
    mdfind ahlstrom 0.04s user 0.06s system 38% cpu 0.259 total

    Whoop de do.

    $ time locate ahlstrom &> /dev/null
    real 0m1.027s
    user 0m0.927s
    sys 0m0.141s

    This is on my computer, and emits 442650 hits (as counted by
    piping the command to wc -l.)

    Another example, a more realistic use of locate:

    $ time locate vim
    real 0m0.043s
    user 0m0.015s
    sys 0m0.023s

    "locate" doesn't locate everything.

    Define "everything".

    "mdfind" and the system it uses indexing everything.

    You really need to be precise, because index all information on
    a disk would be huge.

    $ locate xyz

    This finds about 20 files on this system.

    Fwiw, /var/lib/plocate/plocate.db is about 22 Mb on this system.
    --
    Truth is free, but information costs.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From pothead@pothead@snakebite.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sun May 10 12:24:50 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-10, Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-09 06:06, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:52, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line >>>>>>>>> the word 'cat' is found on and the 3 lines before this line and 2 after?

    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.

    Given that the tools exist to "remember" for you, that hardly matters, >>>>>> and I guarantee you that mdfind is orders of magnitude faster.

    Sounds a bit like UNIX locate/plocate.

    You need to learn a little more about how Apple implemented what in the >>>> GUI part of the OS is called "Spotlight".

    "mdfind" is just a command line tool that leverages the same index that >>>> is created for Spotlight.

    Duh-uh. I found that out on my own.

    I just ran this:

    agbaker@Alans-M3 / % time mdfind ahlstrom

    The result:

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading >>>> keywords and predicates for locale "en_CA"

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading >>>> keywords and predicates for locale "en"

    /Users/agbaker/Library/Group
    Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main
    Profile/Data/Messages/109/6DCA995E-E984-4A01-8FEA-ECF490248F0B.olk15Message

    mdfind ahlstrom 0.04s user 0.06s system 38% cpu 0.259 total

    Whoop de do.

    $ time locate ahlstrom &> /dev/null
    real 0m1.027s
    user 0m0.927s
    sys 0m0.141s

    This is on my computer, and emits 442650 hits (as counted by
    piping the command to wc -l.)

    Another example, a more realistic use of locate:

    $ time locate vim
    real 0m0.043s
    user 0m0.015s
    sys 0m0.023s

    "locate" doesn't locate everything.

    Define "everything".

    "mdfind" and the system it uses indexing everything.

    You really need to be precise, because index all information on
    a disk would be huge.

    $ locate xyz

    This finds about 20 files on this system.

    Fwiw, /var/lib/plocate/plocate.db is about 22 Mb on this system.

    It's 11.3 MB on my system.
    --
    pothead

    "Often imitated, never duplicated."

    "Socialism is the philosophy of failure,
    the creed of ignorance, and the gospel of envy.
    It's inherent virtue is the equal sharing of misery."

    -- Winston Churchill




    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sun May 10 06:25:43 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-10 05:06, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-09 05:59, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:44, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D

    Nope.

    Indexed.

    And cached.

    Nope.

    Yes, there is an index.

    No, nothing was cached.

    Are you saying that MacOS does not cache data? Data such as... an
    index?

    Surely you're joking, Mr. Fine Man!


    An index is not a cache.

    You were trying to imply that it ran fast because it had run immediately before.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sun May 10 06:34:37 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-10 05:16, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-09 06:06, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:52, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-07 03:08, John Bokma wrote:
    On 06/05/2026 22:34, Alan wrote:
    On 2026-05-06 12:57, John Bokma wrote:

    [..]

    Can you show me how to use mdfind to:

    search in all python only files for the word 'cat' showing the line >>>>>>>>> the word 'cat' is found on and the 3 lines before this line and 2 after?

    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all!

    Ok, fair enough, although you need extra commands.

    ag --python -B3 -A2 '\bcat\b'

    Easier to remember.

    Given that the tools exist to "remember" for you, that hardly matters, >>>>>> and I guarantee you that mdfind is orders of magnitude faster.

    Sounds a bit like UNIX locate/plocate.

    You need to learn a little more about how Apple implemented what in the >>>> GUI part of the OS is called "Spotlight".

    "mdfind" is just a command line tool that leverages the same index that >>>> is created for Spotlight.

    Duh-uh. I found that out on my own.

    I just ran this:

    agbaker@Alans-M3 / % time mdfind ahlstrom

    The result:

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading >>>> keywords and predicates for locale "en_CA"

    2026-05-08 11:37:24.286 mdfind[57515:2714553] [UserQueryParser] Loading >>>> keywords and predicates for locale "en"

    /Users/agbaker/Library/Group
    Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main
    Profile/Data/Messages/109/6DCA995E-E984-4A01-8FEA-ECF490248F0B.olk15Message

    mdfind ahlstrom 0.04s user 0.06s system 38% cpu 0.259 total

    Whoop de do.

    $ time locate ahlstrom &> /dev/null
    real 0m1.027s
    user 0m0.927s
    sys 0m0.141s

    This is on my computer, and emits 442650 hits (as counted by
    piping the command to wc -l.)

    Another example, a more realistic use of locate:

    $ time locate vim
    real 0m0.043s
    user 0m0.015s
    sys 0m0.023s

    "locate" doesn't locate everything.

    Define "everything".

    "mdfind" and the system it uses indexing everything.

    You really need to be precise, because index all information on
    a disk would be huge.

    $ locate xyz

    This finds about 20 files on this system.

    Fwiw, /var/lib/plocate/plocate.db is about 22 Mb on this system.


    The Spotlight index for my Data drive is 4.3G, so not small...

    ...but at less than half a percent of my 1TB drive, I wouldn't call it
    "huge".
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sun May 10 12:21:58 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    On 2026-05-10 05:06, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-09 05:59, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:44, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all! >>>>>>>>
    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D

    Nope.

    Indexed.

    And cached.

    Nope.

    Yes, there is an index.

    No, nothing was cached.

    Are you saying that MacOS does not cache data? Data such as... an
    index?

    Surely you're joking, Mr. Fine Man!

    An index is not a cache.

    Duh!

    You were trying to imply that it ran fast because it had run immediately before.

    I'm done with you, so obtuse, on this topic.
    --
    I smell a wumpus.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Sun May 10 21:41:42 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-10 09:21, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-10 05:06, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-09 05:59, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-08 10:44, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    On 2026-05-06 18:34, rbowman wrote:
    On Wed, 6 May 2026 13:34:55 -0700, Alan wrote:


    Sure!

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 | >>>>>>>>>> xargs -0 grep -i -B 3 -A 2 "cat"

    Didn't need to install an additional piece of software at all! >>>>>>>>>
    And this is easier than 'find . -name "*.py" | .....

    Faster... ...like a LOT faster; impossibly faster.

    On my drive with 2,711,067 files, running my command takes...

    (Running it again now)

    ...1 second.

    Cached, obviously :-D

    Nope.

    Indexed.

    And cached.

    Nope.

    Yes, there is an index.

    No, nothing was cached.

    Are you saying that MacOS does not cache data? Data such as... an
    index?

    Surely you're joking, Mr. Fine Man!

    An index is not a cache.

    Duh!

    You were trying to imply that it ran fast because it had run immediately
    before.

    I'm done with you, so obtuse, on this topic.


    So if that isn't what you were implying...

    ...and you acknowledge that an index is not the same thing as a cache...

    ...what WERE you trying to claim?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Mon May 11 10:26:12 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-10 11:33, rbowman wrote:
    On Sun, 10 May 2026 08:16:39 -0400, Chris Ahlstrom wrote:

    $ locate xyz

    This finds about 20 files on this system.

    It finds 134 on mine :) That's what happens when you mess around with GIS stuff. There are a lot of Python and Node library files to handle tile requests. The plocate database is 40 MB.

    My ".Spotlight-V100" directory is 4.3GB...

    ...less than 0.5% of my 1TB drive...

    ...and it lets me find every ".py" file on the entire volume in less
    than a second.

    I guarantee you that 4.3GB of my RAM is not occupied by a "cached"
    version of the index.

    Executing this command on "/" (which has some 2,719,481 files) using the "time" utility:

    mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == 'cat'" -0 |
    xargs -0 grep -i -B 3 -A 2 "cat"

    Which finds ever python file, and prints out 3 lines before and three
    lines after the "cat" in each...

    ...took 0.505 seconds.

    I realize that you Linux advocates have to sign a contract in blood with
    Linus Torvalds before they're allowed to use Linux, but seriously:

    Spotlight works excellently, and you just look foolish when you try to
    compare it to something like "locate".
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Mon May 11 10:26:58 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-11 04:33, Chris Ahlstrom wrote:
    rbowman wrote this screed in ALL-CAPS:

    On Sun, 10 May 2026 08:16:39 -0400, Chris Ahlstrom wrote:

    $ locate xyz

    This finds about 20 files on this system.

    It finds 134 on mine :) That's what happens when you mess around with GIS >> stuff. There are a lot of Python and Node library files to handle tile
    requests. The plocate database is 40 MB.

    Arguing with an Apple fanboi is like mud wrestling a pig.

    Seems so. I explicitly noted that an index can be cached.

    No. You made no such explicit claim...

    ...but good job running away to the safety of COLA.

    :-)
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From MLT@melaniasloosetwat@wicks.org to comp.os.linux.advocacy,comp.sys.mac.advocacy on Tue May 12 01:20:30 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan <nuh-uh@nope.com> wrote in news:10tt3h2$19gng$2@dont-email.me:

    On 2026-05-11 04:33, Chris Ahlstrom wrote:
    rbowman wrote this screed in ALL-CAPS:

    On Sun, 10 May 2026 08:16:39 -0400, Chris Ahlstrom wrote:

    $ locate xyz

    This finds about 20 files on this system.

    It finds 134 on mine :) That's what happens when you mess around
    with GIS stuff. There are a lot of Python and Node library files to
    handle tile requests. The plocate database is 40 MB.

    Arguing with an Apple fanboi is like mud wrestling a pig.

    Seems so. I explicitly noted that an index can be cached.

    No. You made no such explicit claim...

    ...but good job running away to the safety of COLA.

    :-)


    How much is Apple paying you Alan to be an extreme fanboy?
    Whatever it is, they are wasting their money because you are considered a joke. Nobody trusts your post. Most people ignore them.

    So how much you making to spew this garbage?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From CrudeSausage@crude@sausa.ge to comp.os.linux.advocacy,comp.sys.mac.advocacy on Mon May 11 21:36:01 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-11 9:20 p.m., MLT wrote:
    Alan <nuh-uh@nope.com> wrote in news:10tt3h2$19gng$2@dont-email.me:

    On 2026-05-11 04:33, Chris Ahlstrom wrote:
    rbowman wrote this screed in ALL-CAPS:

    On Sun, 10 May 2026 08:16:39 -0400, Chris Ahlstrom wrote:

    $ locate xyz

    This finds about 20 files on this system.

    It finds 134 on mine :) That's what happens when you mess around
    with GIS stuff. There are a lot of Python and Node library files to
    handle tile requests. The plocate database is 40 MB.

    Arguing with an Apple fanboi is like mud wrestling a pig.

    Seems so. I explicitly noted that an index can be cached.

    No. You made no such explicit claim...

    ...but good job running away to the safety of COLA.

    :-)


    How much is Apple paying you Alan to be an extreme fanboy?
    Whatever it is, they are wasting their money because you are considered a joke. Nobody trusts your post. Most people ignore them.

    I know I do.

    So how much you making to spew this garbage?

    They pay him in free Apple stickers.
    --
    CrudeSausage
    M4 MacBook Air
    Islam is the worship of Satan
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Mon May 11 21:20:55 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-11 18:20, MLT wrote:
    Alan <nuh-uh@nope.com> wrote in news:10tt3h2$19gng$2@dont-email.me:

    On 2026-05-11 04:33, Chris Ahlstrom wrote:
    rbowman wrote this screed in ALL-CAPS:

    On Sun, 10 May 2026 08:16:39 -0400, Chris Ahlstrom wrote:

    $ locate xyz

    This finds about 20 files on this system.

    It finds 134 on mine :) That's what happens when you mess around
    with GIS stuff. There are a lot of Python and Node library files to
    handle tile requests. The plocate database is 40 MB.

    Arguing with an Apple fanboi is like mud wrestling a pig.

    Seems so. I explicitly noted that an index can be cached.

    No. You made no such explicit claim...

    ...but good job running away to the safety of COLA.

    :-)


    How much is Apple paying you Alan to be an extreme fanboy?
    Whatever it is, they are wasting their money because you are considered a joke. Nobody trusts your post. Most people ignore them.

    So how much you making to spew this garbage?

    What part of what I just wrote is "garbage"...

    ...more so than calling Apple users "pigs"?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Tue May 12 07:20:57 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    <snip>

    I realize that you Linux advocates have to sign a contract in blood with Linus Torvalds before they're allowed to use Linux, but seriously:

    Asshole.

    Spotlight works excellently, and you just look foolish when you try to compare it to something like "locate".

    No, we don't.
    --
    'Mounten' wird fuer drei Dinge benutzt: 'Aufsitzen' auf Pferde, 'einklinken' von Festplatten in Dateisysteme, und, nun, 'besteigen' beim Sex.
    (Christa Keil in a German posting: "Mounting is used for three things:
    climbing on a horse, linking in a hard disk unit in data systems, and, well, mounting during sex".)
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Tue May 12 09:49:49 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-12 04:20, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    <snip>

    I realize that you Linux advocates have to sign a contract in blood with
    Linus Torvalds before they're allowed to use Linux, but seriously:

    Asshole.

    I literally replied in kind to the way a Linux advocate just described
    Mac users in a post which was a reply to you...

    ...and to which you replied:

    "Arguing with an Apple fanboi is like mud wrestling a pig."

    So why isn't rbowman an "asshole", asshole?


    Spotlight works excellently, and you just look foolish when you try to
    compare it to something like "locate".

    No, we don't.


    You really do.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Chris Ahlstrom@OFeem1987@teleworm.us to comp.os.linux.advocacy,comp.sys.mac.advocacy on Tue May 12 18:48:46 2026
    From Newsgroup: comp.sys.mac.advocacy

    Alan wrote this screed in ALL-CAPS:

    <snip>

    Meh.
    --
    Weinberg's First Law:
    Progress is only made on alternate Fridays.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan@nuh-uh@nope.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Tue May 12 15:52:53 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-12 15:48, Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    <snip>

    Meh.


    Run away, little man!
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From CrudeSausage@crude@sausa.ge to comp.os.linux.advocacy,comp.sys.mac.advocacy on Tue May 12 20:25:01 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-12 6:48 p.m., Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    <snip>

    Meh.


    You've done the right thing, Chris.
    --
    CrudeSausage
    M4 MacBook Air

    "Christians are killing women in this country. And the poor. And
    disabled. And the poor. Look at the "Bible Belt" where all of these
    things and so much more are worse. We are in end-stage capitalized
    fueled by right wing extremist Christians. Muslims do not do nearly the
    harm." - Sodomite Snit Brock McNuggers Michael Glasser, lying shamelessly.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From pothead@pothead@snakebite.com to comp.os.linux.advocacy,comp.sys.mac.advocacy on Wed May 13 00:34:46 2026
    From Newsgroup: comp.sys.mac.advocacy

    On 2026-05-13, CrudeSausage <crude@sausa.ge> wrote:
    On 2026-05-12 6:48 p.m., Chris Ahlstrom wrote:
    Alan wrote this screed in ALL-CAPS:

    <snip>

    Meh.


    You've done the right thing, Chris.

    Indeed he has.
    --
    pothead

    "Often imitated, never duplicated."

    "Socialism is the philosophy of failure,
    the creed of ignorance, and the gospel of envy.
    It's inherent virtue is the equal sharing of misery."

    -- Winston Churchill




    --- Synchronet 3.22a-Linux NewsLink 1.2