Announcement

Collapse
No announcement yet.

Article - How to Clear Bash History on Linux

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by Rod J View Post
    You just type one or more letters of the command(s) you are looking for and each matching command will appear. Just keep typing up or down arrows or add more characters to find the one you're looking for.
    That's a nice complement to ctrl+r search (and one that I would use if I still used bash), not a complete replacement as it only searches commands that begin with what you have typed.

    Originally posted by Rod J View Post
    The second mod allows you to see all previous commands based on a partial input line. I don't use this one so much myself as I've forgotten how to make more use of the list.
    You could run the commands on the list with !# (replacing the # with the command's history number from the list)...this works with any history item, if you know it's number.

    Comment


      #17
      Originally posted by kubicle View Post
      You could run the commands on the list with !# (replacing the # with the command's history number from the list).
      Thanks Kubicle, that was the action I had forgotten!
      Desktop PC: Intel Core-i5-4670 3.40Ghz, 16Gb Crucial ram, Asus H97-Plus MB, 128Gb Crucial SSD + 2Tb Seagate Barracuda 7200.14 HDD running Kubuntu 18.04 LTS and Kubuntu 14.04 LTS (on SSD).
      Laptop: HP EliteBook 8460p Core-i5-2540M, 4Gb ram, Transcend 120Gb SSD, currently running Deepin 15.8 and Manjaro KDE 18.

      Comment


        #18
        There is also this available, if you want something more interactive:
        https://github.com/dvorka/hstr

        EDIT: quickly tried this myself on bash...really nice front-end for ctrl+r search with enough functionality for most needs.

        EDIT2: works with zsh, too...I think this is a keeper.
        Last edited by kubicle; May 02, 2018, 10:45 PM.

        Comment


          #19
          kubicle;
          Thanks, that does look useful.
          Kubuntu 24.11 64bit under Kernel 6.11.0, Hp Pavilion, 6MB ram. Stay away from all things Google...

          Comment


            #20
            hstr looks like a keeper as well!
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #21
              Totally ridiculous exercise idea in my opinion. I e-x-p-a-n-d my history not shorten or clear it. The point of having history is specifically so you DON"T have to go through additional needless steps to preserve previous commands.

              Hmmmm, lets see; I enter a long-ish command using sed and a couple other functions and some real specific fields into my bash terminal

              With history: I type "history | grep sed" and a list of commands I've used in the last 10,000 (the length I set my history to) that include sed appear. I copy and paste the one I'm looking for and re-use it.

              Without history: I have to re-construct the whole command using web searches or browser history (ironic, right?) or referring to my chicken-scratch notes. After several tries, I'll likely figure it out - again - after repeating all the work it took to construct the command the first time.

              Why would I try and guess what commands I might want to use again, copy them to some file somewhere, when bash history does this for me automatically? Clearly, I totally miss the point of doing this.

              If you don't want history, don't use your up-arrow. Or if you actually hate bash history (odd IMO) then edit these lines from ~/.bashrc:

              Code:
              [FONT=monospace][COLOR=#000000]# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)[/COLOR]
              HISTSIZE=1000
              HISTFILESIZE=2000
              [/FONT]

              Please Read Me

              Comment


                #22
                oshunluver;

                For me, bash history contains too much... well... history. It's not a matter of "hate" but rather a lack of need to store seldom used commands. I've moved past whatever I was doing at a prior time and want to have a minimal set of frequently used commands.

                I found that the ability to flush the history Increased my speed of usage and made my daily work easier. Less time spent hunting and more time spent doing my intended tasks.

                YMMV and that is exactly right. "To each his own". "Walk your own road". That is why Linux is so much better than the Other alternative.

                With respect.
                TWP
                Kubuntu 24.11 64bit under Kernel 6.11.0, Hp Pavilion, 6MB ram. Stay away from all things Google...

                Comment

                Working...
                X