Displaced Geek

Just a city geek and father coming to terms with being replanted in farm country

hist2bin v0.5

So as well as it passed my quick QA testing the other day, that last version failed in some major ways:

  1. It didn’t work as a cron job
  2. It only worked locally

So I addressed those issues, but to get the full effect I highly recommend you share your history across all terminals by adding this to your .bashrc:

PROMPT_COMMAND="history -a; history -n"

#!/bin/bash
awk '/##/' ~/.bash_history > ~/testfile2
#d=`date +%N`
N=0
while read line ; do
	d=`date +%N`
	N=$((N+1))
	data=${line%##*}
	file=${line##*##}
	file=$(echo $file | tr A-Z a-z | tr ' ' _)
	if [ ! -f ~/bin/$file ]
	then
		echo $data > ~/bin/$file
	else
		file=$file$d
		echo $data > ~/bin/$file
	fi
	echo "New File #"$N" = "$file
done < ~/testfile2
rm ~/testfile2
history -c
rm ~/.bash_history 
Advertisements

Written by Peter

August 9, 2011 at 1349

Posted in geek

Tagged with , , , ,

%d bloggers like this: