• Skyler@kbin.social
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      This is my approach, and for those who don’t know, you can use those line numbers that come back from history to rerun the command. Like if your output is something like this:

      $ history | grep tmp
        501  ls /tmp
        502  history | grep tmp
      
      

      You can run !501 and it will just re-run ls /tmp

      • runswithjedi@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        Mine is hists for ‘history search’. Interesting how we came up with different names for the same thing.

      • mrmanager@lemmy.today
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        1 year ago

        Wait until you learn about ctrl-R to search the bash history… :) If you press that and start typing, you will get auto complete from previous commands you typed. This is how an experienced linux user can be so fast in the terminal.

        There are even better tools for this, so ctrl R is just the built in way. Later you should look into https://github.com/junegunn/fzf

      • runswithjedi@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        grep is sooo useful. Combined with piping commands it can do some really powerful stuff. I didn’t really understand a lot of these commands until I took a Linux class at my local community college. That helped a lot.