.bash_histoty

Stuart Sears stuart at sjsears.com
Thu Apr 21 21:09:30 UTC 2005


On Thu, 2005-04-21 at 16:42 -0400, Ralph E. Kenyon, Jr. wrote:
> Is it possible to alter the functioning of bash_history?
> 
> I would like to see a duplicate entry treated as follows:
> 
> Bring it to the bottom (deleting the prior entry)
> 
> So that the "adjusted" history has a list of commands, without duplicates,  
> in the order that they were last used.
> 
> Is it possible to "hack" this functionality in in some way?
hacking is not really needed - bash has similar functionality built in.

man bash (and a bit of judicious searching) gives...
HISTCONTROL 
A colon-separated list of values controlling how commands are saved on
the history list. If the list of values includes ignorespace, lines
which begin with a space character are not saved in the history list. A
value of ignoredups causes lines matching the previous history entry to
not be saved. A value of ignoreboth is shorthand for ignorespace and
ignoredups. A value of erasedups causes all previous lines matching the
current line to be removed from the history list before that line is
saved. Any value not in the above list is ignored. If HISTCONTROL is
unset, or does not include a valid value, all lines read by the shell
parser are saved on the history list, subject to the value of
HISTIGNORE. The second and subsequent lines of a multi-line compound
command are not tested, and are added to the history regardless of the
value of HISTCONTROL.

export HISTCONTROL=erasedups
in your ~/.bash_profile should do the trick (or something very much like
it)

HTH

Stuart
--
Stuart Sears RHCE RHCX RTFM




More information about the Redhat-install-list mailing list