Skip to content

Instantly share code, notes, and snippets.

@ecerulm
Created August 1, 2010 23:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecerulm/503907 to your computer and use it in GitHub Desktop.
Save ecerulm/503907 to your computer and use it in GitHub Desktop.
echo copying local history file
history -a
cp .bash_history full_history
HOSTS="machine1.example.com machine2.example.com"
for i in $HOSTS; do
echo copying history file from $i
scp $i:~/.bash_history tmp_history.txt
cat tmp_history.txt >>full_history
wc -l tmp_history.txt
wc -l full_history
done
echo sorting the new history file and removing duplicates
sort full_history|uniq >uniq_history
rm full_history
echo replacing history file with the new one
mv uniq_history .bash_history
echo reloading bash history from file
history -c
history -r
wc -l .bash_history
for i in $HOSTS; do
echo backing up .bash_history in $i
DATE=`date '+%Y%m%d%H%M%S'`
ssh $i "cp ~/.bash_history ~/.bash_history$DATE"
echo replacing .bash_history in $i
scp .bash_history $i:~/.bash_history
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment