Am 2008-11-26 15:28:47, schrieb Robert Holtzman: > I've been going thru a number of bash related web sites looking for the > way to eliminate duplicates in ~/.bash_history. So far I've turned up > > export HISTCONTROL=ignoredups > export HISTCONTROL=erasedups > awk '!x[$0]++' .bash_history > .bash.tmp && mv -f .bash.tmp .bash_history > export HISTCONTROL=ignoreboth > > Tried them all in ~/.bashrc one at a time and rerunning .bashrc each time. > So far no joy. Any pointers and/or sources appreciated.
I use this: ----[ '~/.bash_logout' ]------------------------------------------------ # created by tdbash # UPDATED: Wed, 12 Mar 2008 16:21:46 +0100 # ~/.bash_logout: executed by bash(1) at logout for SLEEP in 1 2 3 4 5 ; do if [ -f ~/.bash_history.lock ] then sleep 1 else break fi done if [ ! -f ~/.bash_history.lock ] ; then touch ~/.bash_history.lock # Number the ~/.bash_history echo 0 >~/.bash_history.count (cat ~/.bash_history) | while read LINE do COUNT=$(cat ~/.bash_history.count) printf "%04i %s\n" $COUNT "$LINE" >>~/.bash_history.tmp1 COUNT=$((COUNT+1)) echo $COUNT >~/.bash_history.count done # Reverse the ~/.bash_history sort -r ~/.bash_history.tmp1 |cut -c 6- >~/.bash_history.tmp2 # Check the ~/.bash_history for dups echo >~/.bash_history.tmp3 (cat ~/.bash_history.tmp2) | while read LINE do grep --regexp="$LINE" ~/.bash_history.tmp3 >/dev/null 2>&1 if [ $? -ne 0 ] ; then echo -e "${LINE}" >>~/.bash_history.tmp3 fi done # Un-Reverse the ~/.bash_history if [ $(wc -c <~/.bash_history.tmp3) -gt 100 ] ; then # Number the ~/.bash_history echo 0 >~/.bash_history.count (cat ~/.bash_history.tmp3) | while read LINE do COUNT=$(cat ~/.bash_history.count) printf "%04i %s\n" $COUNT "$LINE" >>~/.bash_history.tmp4 COUNT=$((COUNT+1)) echo $COUNT >~/.bash_history.count done # Un-Reverse the ~/.bash_history sort -r ~/.bash_history.tmp4 |cut -c 6- |grep -v '^$' >~/.bash_history fi /bin/rm -f ~/.bash_history.tmp* ~/.bash_history.count ~/.bash_history.lock fi reset ------------------------------------------------------------------------ Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack Apt. 917 ICQ #328449886 +49/177/9351947 50, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
signature.pgp
Description: Digital signature