#!/bin/ksh # TODO: # - make the script runable from any directory (GOPHERBLOG variable?) # - if no text file, fetch it from stdin # - check for 1st, 2nd and 3rd of the month and adjust the date prefix # - add a full interactive mode? if [[ -z $1 ]] || [[ -z $2 ]]; then echo "USAGE: mkgopherentry title textfile" exit 1 fi intro=`cat $2 | awk 'BEGIN { N = 0} /^$/ {N = 1} {if (N == 0) print;}'` # cat the header cat gophermap_header > gophermap.tmp # Create an entry. cat >>gophermap.tmp<<EOF --$1-- `date "+%A, %B %dth, %Y"` $intro 0Continued... $2 EOF LN=`wc gophermap | awk '{print $1}'` let LN=$((LN))-11; cat gophermap | tail -$LN > gophermap_footer # Add the old ones to its tail. if [[ -f gophermap ]]; then cat gophermap_footer >> gophermap.tmp fi mv gophermap.tmp gophermap chmod 640 gophermap $2