Genivia / ugrep

NEW ugrep 6.5: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more
https://ugrep.com
BSD 3-Clause "New" or "Revised" License
2.56k stars 109 forks source link

max-count across all files #378

Closed NightMachinery closed 4 months ago

NightMachinery commented 4 months ago

Basically this question: https://stackoverflow.com/questions/14093452/grep-only-the-first-match-and-stop

I want ugrep to search a dir and stop on its first match.

ugrep --hidden --file-extension=org --json --dereference-recursive --files-with-matches --max-count=1 --line-number \^\\s\*\:ID\:\\s\+203753a3-c849-48a0-bd4e-11e0bdc566b6 /my/dir

But this continues to search other files after finding a match. I can't use the head -1 trick, as I am using --json.

genivia-inc commented 4 months ago

You mean the --max-files=MAX option? For example, --max-files=1 finds the first matching file.

NightMachinery commented 4 months ago

Thanks, that was it.