Groups | Search | Server Info | Login | Register


Groups > comp.os.linux.advocacy > #712527

Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”

From Chris Ahlstrom <OFeem1987@teleworm.us>
Newsgroups comp.os.linux.advocacy, comp.sys.mac.advocacy
Subject Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”
Date 2026-05-09 09:06 -0400
Organization None
Message-ID <10tnbgp$3kvct$4@dont-email.me> (permalink)
References (5 earlier) <10tg8lf$1fq2g$1@dont-email.me> <10thoas$1umls$1@dont-email.me> <10ti7h4$249ag$1@dont-email.me> <10tl7su$32i9q$2@dont-email.me> <10tlaji$336rn$1@dont-email.me>

Cross-posted to 2 groups.

Show all headers | View raw


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!!

Back to comp.os.linux.advocacy | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

“5 MacOS command line tools I swear by over their GUI counterparts” Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-05 00:54 +0000
  Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-04 18:14 -0700
    Re: “5 MacOS command line tools I swear by over their GUI counterparts” "Joel W. Crump" <joelcrump@gmail.com> - 2026-05-04 21:24 -0400
      Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-04 18:58 -0700
      SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-05 17:13 +0200
        Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-05 11:20 -0400
          Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-05 17:31 +0200
            Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-05 12:02 -0400
              Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-05 18:08 +0200
                Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) Alan <nuh-uh@nope.com> - 2026-05-05 09:14 -0700
                Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-05 18:49 +0200
                Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-05 13:21 -0400
                Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) Alan <nuh-uh@nope.com> - 2026-05-05 11:22 -0700
        Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) "Joel W. Crump" <joelcrump@gmail.com> - 2026-05-05 13:35 -0400
          Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-05 19:41 +0200
            Re: SSD prices (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-05 13:53 -0400
              Re: SSD prices (was Re: �5 MacOS command line tools I swear by over their GUI counterparts�) chrisv <chrisv@nospam.invalid> - 2026-05-05 15:36 -0500
                Re: SSD prices (was Re: 5 MacOS command line tools I swear by over their GUI counterparts) CrudeSausage <crude@sausa.ge> - 2026-05-05 18:45 -0400
    Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 17:11 +0200
      Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-05 08:50 -0700
        Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 17:54 +0200
          Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-05 09:06 -0700
            Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 18:13 +0200
              Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-05 09:16 -0700
                Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 18:59 +0200
                Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-05 10:04 -0700
                Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 19:24 +0200
  Re: “5 MacOS command line tools I swear by over their GUI counterparts” CrudeSausage <crude@sausa.ge> - 2026-05-05 08:55 -0400
    Re: “5 MacOS command line tools I swear by over  their GUI counterparts” (was: “5 MacOS command line tools I swear by over  their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 13:54 +0000
      Re: “5 MacOS command line tools I swear by over their GUI counterparts” "Joel W. Crump" <joelcrump@gmail.com> - 2026-05-05 10:24 -0400
        Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-05 08:51 -0700
        Re: “5 MacOS command line tools I swear by over  their GUI counterparts” (was: “5 MacOS command line tools I swear by over  their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 17:27 +0000
          Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 19:32 +0200
            Re: “5 MacOS command line tools I swear by over  their GUI counterparts” (was: “5 MacOS command line tools I swear by over  their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 17:50 +0000
              Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 19:55 +0200
                Re: “5 MacOS command line tools I swear by over  their GUI counterparts” (was: “5 MacOS command line tools I swear by over  their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 17:59 +0000
                Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 20:04 +0200
                Re: “5 MacOS command line tools I swear by over  their GUI counterparts” (was: “5 MacOS command line tools I swear by over  their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 18:14 +0000
                Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 20:15 +0200
                Re: “5 MacOS command line tools I swear by over their GUI counterparts” Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-05 22:37 +0000
                Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-06 16:44 +0200
              Re: “5 MacOS command line tools I swear by over their GUI counterparts” Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-05 22:18 +0000
                Re: “5MacOS command line tools I swear by over their GUI counterparts” (was: “5MacOS command line tools I swear by over their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 22:48 +0000
          Re: “5 MacOS command line tools I swear by over their GUI counterparts” "Joel W. Crump" <joelcrump@gmail.com> - 2026-05-05 14:26 -0400
            Re: “5 MacOS command line tools I swear by over  their GUI counterparts” (was: “5 MacOS command line tools I swear by over  their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 18:46 +0000
      Re: “5 MacOS command line tools I swear by over  their GUI counterparts” (was: “5 MacOS command line tools I swear by over  their GUI counterparts”) Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-05 21:45 +0000
        Re: �5 MacOS command line tools I swear by over  their GUI counterparts� (was: �5 MacOS command line tools I swear by over  their GUI counterparts�) chrisv <chrisv@nospam.invalid> - 2026-05-05 17:02 -0500
        Re: “5MacOS command line tools I swear by over  their GUI counterparts” (was: “5MacOS command line tools I swear by over  their GUI counterparts”) Brock McNuggets <brock.mcnuggets@gmail.com> - 2026-05-05 23:00 +0000
    Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-05 08:51 -0700
  Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 17:08 +0200
  Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-05 17:37 +0200
    Re: “5 MacOS command line tools I swear by over their GUI counterparts” Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-05 21:46 +0000
      Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-06 16:41 +0200
        Re: “5 MacOS command line tools I swear by over their GUI counterparts” CrudeSausage <crude@sausa.ge> - 2026-05-06 12:24 -0400
          Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-06 18:27 +0200
            Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-06 12:31 -0400
              Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-06 18:45 +0200
                Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-06 12:56 -0400
                Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-06 19:09 +0200
                Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-06 14:04 -0400
                Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-06 21:58 +0200
                Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-06 18:45 -0400
                Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) CrudeSausage <crude@sausa.ge> - 2026-05-06 14:05 -0400
                Re: Nix (was Re: “5 MacOS command line tools I swear by over their GUI counterparts”) John Bokma <contact@johnbokma.com> - 2026-05-06 22:00 +0200
  mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-06 10:37 -0700
    Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-06 19:52 +0200
      Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-06 11:58 -0700
        Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-06 21:57 +0200
          Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-06 13:34 -0700
            Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” rbowman <bowman@montana.com> - 2026-05-07 01:34 +0000
              Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-06 19:31 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-08 13:44 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-08 11:33 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-09 08:59 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-09 06:09 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-10 08:06 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-10 06:25 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-10 12:21 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-10 21:41 -0700
            Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” John Bokma <contact@johnbokma.com> - 2026-05-07 12:08 +0200
              Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-07 07:27 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-08 13:52 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-08 11:38 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-09 09:06 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-09 06:10 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-10 08:16 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” pothead <pothead@snakebite.com> - 2026-05-10 12:24 +0000
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-10 06:34 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” rbowman <bowman@montana.com> - 2026-05-10 18:33 +0000
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-11 07:33 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-11 10:26 -0700
                Re: Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” MLT <melaniasloosetwat@wicks.org> - 2026-05-12 01:20 +0000
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” CrudeSausage <crude@sausa.ge> - 2026-05-11 21:36 -0400
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-11 21:20 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Alan <nuh-uh@nope.com> - 2026-05-11 10:26 -0700
                Re: mdfind vs ag (was Re: “5 MacOS command line tools I swear by over their GUI counterparts” Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-05-12 07:20 -0400

csiph-web