[HN Gopher] Ugrep - a more powerful, fast, user-friendly, compat...
       ___________________________________________________________________
        
       Ugrep - a more powerful, fast, user-friendly, compatible grep
        
       Author : smartmic
       Score  : 91 points
       Date   : 2023-12-30 21:17 UTC (1 hours ago)
        
 (HTM) web link (ugrep.com)
 (TXT) w3m dump (ugrep.com)
        
       | infamia wrote:
       | Ugrep is also available in Debian based repos, which is super
       | nice.
        
       | dmlerner wrote:
       | Why not ripgrep?
        
         | devraza wrote:
         | From the ugrep README:
         | 
         | For an up-to-date performance comparison of the latest ugrep,
         | please see the ugrep performance benchmarks [at
         | https://github.com/Genivia/ugrep-benchmarks]. Ugrep is faster
         | than GNU grep, Silver Searcher, ack, sift. Ugrep's speed beats
         | ripgrep in most benchmarks.
        
           | codetrotter wrote:
           | Does these performance comparison take into account the
           | things BurntSushi (ripgrep author) pointed out in the ripgrep
           | issue link elsewhere ITT?
           | https://github.com/BurntSushi/ripgrep/discussions/2597
           | 
           | Either way, ripgrep is awesome and I'm staying with it.
        
         | 0cf8612b2e1e wrote:
         | I assume the grep compatible bit is attractive to some people.
         | Not me, but they exist.
        
           | derriz wrote:
           | I find myself returning to grep from my default of rg because
           | I'm just too lazy to learn a new regex language. Stuff like
           | word boundaries "\<word\>" or multiple patterns
           | "\\(one\|two\\)".
        
             | masklinn wrote:
             | That seems like the weirdest take ever: ripgrep uses pretty
             | standard PCRE patterns, which are a lot more common than
             | posix's bre monstrosity.
             | 
             | To me the regex langage is very much a reason to not use
             | grep.
        
               | pbhjpbhj wrote:
               | `pgrep`, or `grep -P`, uses PCRE though, AFAIUI.
        
               | derriz wrote:
               | A bit hyperbolic, no?
               | 
               | If you consider it "the weirdest ever", I'm guessing that
               | I'm probably older than you. I've certainly been using
               | regex long before PCRE became common.
               | 
               | As a vim user I compose 10s if not 100s of regexes a day.
               | It does not use PCRE. Nor does sed, a tool I've been
               | using for decades. Do you also recommend not using these?
        
             | burntsushi wrote:
             | ripgrep's regex syntax is pretty similar to grep -E. So if
             | you know grep -E, most of that will transfer over.
             | 
             | Also, \< and \> are in ripgrep 14. Although you usually
             | just want to use the -w/--word-regexp flag.
        
               | xoranth wrote:
               | > Also, \< and \> are in ripgrep 14
               | 
               | Isn't that inconsistent with the way Perl's regex syntax
               | was designed? In Perl's syntax an escaped non-ASCII
               | character is always a literal [^1], and that is
               | guaranteed not to change.
               | 
               | That's nice for beginners because it saves you from
               | having to memorize all the metacharacters. If you are in
               | doubt you on whether something has a special meaning, you
               | just escape it.
               | 
               | [^1]: https://perldoc.perl.org/perlrebackslash#The-
               | backslash
        
         | meindnoch wrote:
         | Because this is faster?
        
         | bsdpufferfish wrote:
         | ripgrep stole the name but doesn't follow the posix standard.
        
         | Conscat wrote:
         | The best practical reason to choose this is its interactive
         | features, like regexp building.
        
         | tredre3 wrote:
         | One thing I never liked about ripgrep is that it doesn't have a
         | pager. Yes, it can be configured to use the system-wide ones,
         | but it's an extra step (and every time I have to google how to
         | preserve colors) and on Windows you're SOL unless you install
         | gnu utils or something. The author always refused to fix that.
         | 
         | Ugrep not only has a pager built in, but it also allows
         | searching the results which is super nice! And that feature
         | works on all supported platforms!
        
           | burntsushi wrote:
           | This is what I do personally:                   $ cat
           | ~/bin/rgp         #!/bin/sh         exec rg -p "$@" | less
           | -RFX
           | 
           | Should work just fine. For Windows, you can install `bat` to
           | use a pager if you don't otherwise have one. You don't need
           | GNU utils to have a pager.
        
           | bornfreddy wrote:
           | Interesting - for me a built-in pager is an antifeature. I
           | don't want to figure out how to leave the utility. Worst of
           | all, pager usually means that sometimes you get more pages
           | and you need to press q to exit, and sometimes not. Annoying.
           | I often type yhe next command right away and the pager means
           | I get stuck, or worse, pager starts doing something in
           | response to my keys (looking at you, `git log`).
           | 
           | Then again I'm on Linux and can always pipe to less if I need
           | to. I'm also not the target audience for ugrep because I've
           | never noticed that _grep_ would be slow. :shrug:
        
       | graphe wrote:
       | Here's a thread on performance vs rg (ripgrep).
       | https://github.com/BurntSushi/ripgrep/discussions/2597 didn't
       | know about hypergrep either.
        
       | mathverse wrote:
       | Also look at https://github.com/stealth/grab from Sebastian
       | Krahmer.
        
       | jraph wrote:
       | Okay, this solves a feature I was occasionally missing for a long
       | time: searching for several terms in files (the "Googling files"
       | feature). I wrote a 8 line script a few weeks ago to do this,
       | that I will gladly throw away. I'll look into the TUI too.
       | 
       | (I've been using ripgrep for quite some time now, how does this
       | otherwise compare to it? would I be able to just replace rg with
       | ug?)
        
       | o11c wrote:
       | Important note: not actually compatible. It took me _seconds_ to
       | find an option that does something completely different than the
       | GNU version.
        
         | fwip wrote:
         | Which option is that? I'm scanning the ugrep page, but nothing
         | is popping out to me.
        
         | e12e wrote:
         | I would assume compatible meant posix/bsd - unless explicitly
         | advertised AS "GNU grep compatible"?
        
           | burntsushi wrote:
           | From the OP: "Ugrep is compatible with GNU grep and supports
           | GNU grep command-line options."
        
         | burntsushi wrote:
         | Indeed. And here are some concrete examples around locale:
         | $ grep -V | head -n1         grep (GNU grep) 3.11         $
         | alias ugrep-grep="ugrep-4.4.1 -G -U -Y -. --sort -Dread -dread"
         | $ echo 'pokemon' | LC_ALL=en_US.UTF-8 grep 'pok[[=e=]]mon'
         | pokemon         $ echo 'pokemon' | LC_ALL=en_US.UTF-8 ugrep-
         | grep 'pok[[=e=]]mon'         $ echo 'g' | LC_ALL=en_US.UTF-8
         | grep -i 'G'         g         $ echo 'g' | LC_ALL=en_US.UTF-8
         | ugrep-grep -i 'G'
         | 
         | BSD grep works like GNU grep too:                   $ grep -V
         | grep (BSD grep, GNU compatible) 2.6.0-FreeBSD         $ echo
         | 'pokemon' | LC_ALL=en_US.UTF-8 grep 'pok[[=e=]]mon'
         | pokemon         $ echo 'g' | LC_ALL=en_US.UTF-8 grep -i 'G'
         | g
        
       | ww520 wrote:
       | Just tried it out. It's blazingly fast. The interactive TUI
       | search is pretty sweet.
        
       ___________________________________________________________________
       (page generated 2023-12-30 23:00 UTC)