Scratchpad

Scratchpad

A blog, of sorts, intended as a place to experiment, struggle, question, and play with whatever research I am currently working on. The themes will thus change over time as my projects change, and the entries may be quotations that strike my fancy, attempts to puzzle through hairy problems, notes on sources, experiments, musings, dead ends, odd angles of looking at things. It is a voice to my frustrations, discoveries, curiosities, and confusions. It is thinking out loud. ...More subscribe to this blog

Reverse dumping lynx links

, ,

9 Jun 2010

Another boring code snippet for me to remember. How to get lynx references back into hyperlinked format.


lynx -dump URL > filename.txt

for i in $(egrep ^" *[0-9]*\." filename.txt | sed -e 's/^ *//g' | cut -f1 -d ".");
do egrep ^" *\[*$i(\.|\])" filename.txt | tac | perl -p -i -e 's/\n//g' | perl -p -i -e 's/ [0-9]*\. /\n<a href="/g' | tr -s " " | perl -p -i -e 's/ \[[0-9]*\]/">/g' | sed '/^ *$/d' | sed -e 's/$/<\/a><br \/>\n/g' >> filename-clean.html;
done