Results 1 to 8 of 8

Thread: How to achieve no bash history deletion

  1. #1
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    How to achieve no bash history deletion

    Like many in Ubuntu i use the amazing
    incremental history searching

    Now I have noticed over a few years that the entire bash history gets wiped out from time to time rendering the incremental search null and void; having to start all over again and remembering commands

    Reading around it seems when it get to a certain numbers it wipes out all the history
    Am I right in thinking that?


    and using
    Code:
    gedit  ~/.bashrc
    and finding

    HISTSIZE=1000
    HISTFILESIZE=2000 you will see the numbers are set quite low

    I understand when it reaches one of those numbers it will WIPE all memory of previous history


    so to set them much higher say

    HISTSIZE=100000
    HISTFILESIZE=200000 and then enter
    Code:
    . ~/.bashrc
    should keep me happy until next OS clean upgrade



    But surely there must be a way to set it to infinite so your incremental history search is ALWAYS secure

    i found this online to do the reverse [ie keep no history]

    Prevent a bash history file from ever being saved


    Add the following commands to ~/.bashrc file:
    echo 'unset HISTFILE' >> ~/.bashrc
    echo 'export LESSHISTFILE="-"' >> ~/.bashrc
    so there must be an equivalent command to do what it is i wish for: ie unlimited bash history


    Might some of you know what it is please?
    Last edited by shantiq; August 8th, 2013 at 09:08 AM.
    Linux is Latin for off-the-beaten-track
    ShanArt XmmsPurple Piper

  2. #2
    Join Date
    Nov 2008
    Location
    Sheffield, UK
    Beans
    1,517
    Distro
    Ubuntu

    Re: How to achieve no bash history deletion

    It wont wipe it all, it justs overwrites the oldest entry. Setting the number higher should be enough

  3. #3
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to achieve no bash history deletion

    hhmmmm so the wiping out must be when i have a freeze and have to pull the lead out... so it happens when i do an "emergency stop" ... i always wondered what the cause was

    thanx for that ... still there must be a way to write this infinity line ... but academic i suppose 100000 should be enough ::]]]
    Linux is Latin for off-the-beaten-track
    ShanArt XmmsPurple Piper

  4. #4
    Join Date
    Jun 2007
    Beans
    14,326

    Re: How to achieve no bash history deletion

    You should keep in mind that the larger the history file the slower your terminal will open, though slow is quite relative.
    Unfortunately bash doesn't have any great means to prevent duplicate entries except in a current terminal session so if you look you'll find many common commands duped numerous times.
    Without dupes it's quite unlikely you'd need much more than 5000 or so, if that..

    You can make use of HISTIGNORE= to prevent some from being duped though I've found that to be a bit of a pita for various reasons except for a few basic ones.
    Here I do backup .bash_history from time to time & also make use of a script to clean dupes. (I always back up before cleaning
    (there are several scripts floating around, the one I currently use doesn't quite keep ordering, one that does seemed to not work as well, ie. removed some commands completely.

    Anyway you can search this out easily (.bash_history does not erase dups), currently I'm using the perl script from here, reply 3, under "But I still need to remove duplicates from time to time:" -
    https://bugs.launchpad.net/ubuntu/+s...sh/+bug/189881

    The ordering, if changed, doesn't matter here as I use a recall previous command search based on char(s) typed rather than going back in order with arrow key..
    Last edited by mc4man; August 8th, 2013 at 05:19 PM.

  5. #5
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to achieve no bash history deletion

    Hi mc4 great info also here in 8 9 and 10 on dupes



    PS:


    also my tip to chase "old" commands
    history|grep -i asectionofthecommandyouarelookingfor
    works better for me than any other i have tried and there are repeats that way ut it is fast and i always see what i am looking for straightaway


    example:

    history|grep -i bash
    28 echo "HISTCONTROL=ignoredups" >>~/.bashrc
    29 leafpad ~/.bashrc
    54 gnome-open .bash_history
    55 echo "HISTCONTROL=ignoredups" >>~/.bashrc
    56 leafpad ~/.bashrc
    71 history|grep -i bash


    Last edited by shantiq; August 8th, 2013 at 06:32 PM.
    Linux is Latin for off-the-beaten-track
    ShanArt XmmsPurple Piper

  6. #6
    Join Date
    Jan 2010
    Location
    Hyperborea
    Beans
    1,661
    Distro
    Ubuntu

    Re: How to achieve no bash history deletion

    This is a good tip, in fact it is the best one.
    http://codeinthehole.com/writing/the...-with-inputrc/

  7. #7
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to achieve no bash history deletion

    absolutely Coldraven but
    history|grep -i asectionofthecommandyouarelookingfor
    is for command you do not remember the first 2 or 3 first letters of; but remember a key word seee what i mean ::]]
    Linux is Latin for off-the-beaten-track
    ShanArt XmmsPurple Piper

  8. #8
    Join Date
    Jan 2010
    Location
    Hyperborea
    Beans
    1,661
    Distro
    Ubuntu

    Re: How to achieve no bash history deletion

    Quote Originally Posted by shantiq View Post
    absolutely Coldraven but is for command you do not remember the first 2 or 3 first letters of; but remember a key word seee what i mean ::]]
    I've sobered up enough now to understand I will definitely use it, thanks.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •