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

Use `--and` with `-g`. #393

Closed hongyi-zhao closed 3 months ago

hongyi-zhao commented 3 months ago

See below:

werner@x13dai-t:~/Public/repo/github.com/materialsproject/pymatgen.git$ ugrep -i 'Paths tried' -g '*.py' -g '**/pymatgen/**'
Binary file pymatgen/io/vasp/__pycache__/inputs.cpython-311.pyc matches
pymatgen/io/vasp/inputs.py:            f"in your {PMG_VASP_PSP_DIR=}. Paths tried: {paths_to_try}"
werner@x13dai-t:~/Public/repo/github.com/materialsproject/pymatgen.git$ ugrep -i 'Paths tried' -g '*.py' --and -g '**/pymatgen/**'
ugrep: warning: Paths tried: No such file or directory

So, how to use --and with -g?

Regards, Zhao

genivia-inc commented 3 months ago

The --and option applies to patterns, not to globs. The -g option can be repeated to specify addtiional globs. Or you can use a comma to specify multiple globs like -g '*.py,**/pymatgen/**'.

    -g GLOBS, --glob=GLOBS, --iglob=GLOBS
            Only search files whose name matches the specified comma-separated
            list of GLOBS, same as --include=glob for each `glob' in GLOBS.
            When a `glob' is preceded by a `!' or a `^', skip files whose name
            matches `glob', same as --exclude='glob'.  When `glob' contains a
            `/', full pathnames are matched.  Otherwise basenames are matched.
            When `glob' ends with a `/', directories are matched, same as
            --include-dir='glob' and --exclude-dir='glob'.  A leading `/'
            matches the working directory.  Option --iglob performs
            case-insensitive name matching.  This option may be repeated and
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
            may be combined with options -M, -O and -t to expand searches.  See
            `ugrep --help globs' and `man ugrep' section GLOBBING for details.