#!/bin/bash # you can blame this mess on Terry Vessels, aka "grouch" # released under the terms of the GPL, http://www.gnu.org/licenses/gpl.txt # an attempt to create a script to generate some anchor tags # in selected file # # s_file == source file # d_file == destination file, without anchors # l_file == destination file, with anchor links s_file=$1 d_file=$2 l_file=$3 # test for existing or zero-length files #if [ ! -f ${s_file} ]||[ -z ${s_file} ]||[ -z ${d_file} ] #then # echo "Usage: $0 [source file] [destination file] [link 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 #if [ -e $3 ] #then # echo "link file $3 exists!" # echo "either choose another filename to write to, or rm $2" # exit #fi # change all CR (\015) to LF (\012) # put back LF in front of each < and after each > # take out blank lines # awk to insert an [[number]] tag # for each
/>\ /g' |\ grep '[^[:space:]].' | tee $d_file |\ awk 'BEGIN{FS=""}{ #there is probably an easier way to do a case insensitive test if ( ($1=="<") && ((($2=="p") || ($2=="P")) && (($3!="r") || ($3!="R"))) ){ #make an anchor tag using NR (Number of current Record) print "[["NR"]]