Created
August 1, 2010 23:46
-
-
Save ecerulm/503907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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