• wewbull@feddit.uk
    link
    fedilink
    English
    arrow-up
    3
    ·
    4 days ago

    The one people see me doing that gets a “huh?” Is:

    ~$ !find
    find -type f -name '*blah*' -print0 | xargs -0 gzip
    ~$
    

    “Wait! What did you do?” “Oh. Do you not know about bang?”

    • UpperBroccoli@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      9
      ·
      4 days ago

      I love the excitement of using !?

      Did I remember correctly what command sequence I last used that pattern with? Will my data be gone? Will I send a vulgar email to my boss? Who knows, let’s find out!

    • merc@sh.itjust.works
      link
      fedilink
      arrow-up
      7
      ·
      4 days ago

      I don’t understand people who have the confidence to just blindly run the last matching command like that. Like, are you 100% sure that the last time you ran find was that one, not the one that piped to xargs rm?

      At least with zsh you can tab to complete the !find and verify it’s what you want before running it. And, AFAIK by default, the shell option hist_verify is set, so if you do just type !find and hit enter, it doesn’t run the command, it loads the command into the editing buffer so you can look it over first. Maybe I just have a weak memory, but I really appreciate the footgun prevention. At worst I have to hit enter twice. At best, I save myself a lot of grief.

      • wewbull@feddit.uk
        link
        fedilink
        English
        arrow-up
        1
        ·
        3 days ago

        Normally the use case is

        • Constructed a long command, but it didn’t work for some reason.
        • I go fix the reason it didn’t work
        • I do the first thing again

        It’s in my recent memory, but maybe there’s been 10 or so commands of me fixing stuff in-between.