#!/bin/sh
if [ $# != 2 ]; then
	echo "usage: "`basename $0`" WKN URL"
	exit 1
fi

echo -n "if check there are no queued WKNs please type y followed by ENTER: "
read VALUE
if [ `echo $VALUE` = "y" ]; then
	FILE=$HOME/lynx_bookmarks.html
	grep -v $1 $FILE > $FILE.tmp
	grep $1 $FILE | awk -F"=" '{ORS=""; print $1"="}' >> $FILE.tmp
	echo -n $2">" >> $FILE.tmp
	grep $1 $FILE | awk -F">" '{ORS=""; print $3,$4; \
	ORS="\n"; print ">"}' | sed 's/ >/>/g' >> $FILE.tmp
	mv $FILE.tmp $FILE
	for a in anleihen long
	do
		grep $1 $HOME/bin/$a | awk '{ORS=" "; print $1}' > $a.tmp
		echo $2 >> $a.tmp
		grep -v $1 $HOME/bin/$a >> $a.tmp
		mv $a.tmp $HOME/bin/$a
	done
fi
