#!/bin/bash # you can blame this mess on Terry Vessels, aka "grouch" # thanks to "pb" in irc.fdfnet.net#groklaw for eliminating my awk dependency # released under the terms of the GPL, http://www.gnu.org/licenses/gpl.txt # an attempt to create a script to generate some bibliography-style # link lists from groklaw.net articles s_file=$1 d_file=$2 if [ ! -f ${s_file} ]||[ -z ${s_file} ]||[ -z ${d_file} ] then echo "Usage: $0 [source file] [destination file]" exit fi if [ -e $2 ] then echo "destination file $2 exists!" echo "either choose another filename to write to, or rm $2" exit fi # get everything between # and # change all CR to LF, then all LF to SPACE # put back LF in front of each art_start=$(grep -n '' ${s_file} |\ awk '{line_num=substr($1,0,index($1,":")-1); print line_num}') art_end=$(grep -n '' ${s_file} |\ awk '{line_num=substr($1,0,index($1,":")-1); print line_num}') art_len=$((1 + ${art_end} - ${art_start})) c=1 head -${art_end} ${s_file} | tail -${art_len} |\ tr '\015' '\012' | tr '\012' '\040' |\ sed -e 's//<\/a>\ /g' |\ grep "" let c++ done > ${d_file}