# finds most recently modified html file in and beneath current directory, # excluding "noshow" directory and makes a symbolic link to it # This was contributed by Michael Jinks 3/03. It surely needs to have a symbolic link "newest.html" defined and the variable $NF defined.. I also narrowed the -name criteria for a hit and may have introduced syntax error. tw 3/3/03 #!/bin/sh NEWEST=newest.html find . -follow ( -path '*/noshow/*' -prune \) -o -type f -name \*\.?htm\? -newer `ls -l $NEWEST | awk '{print $NF}'` \ -exec ln -sf {} $NEWEST \; # this works if you just type it in:. newest.html must be removed. find . -follow \( -path '*/noshow/' -prune \) -o -name '*\.*htm*' -type f -newer README.html -not -path '*/\.*' -exec ln -sf {} newest.html \; # this works if you just type it in:. newest.html must be removed. set newest = `ls -L newest.html` # rm -f newest.html # preceding command is not needed to prevent link to self. If newest file is unchanged, find will not do anything. find . -follow \( -path '*/noshow/' -prune \) -o -name '*\.*htm*' -type f -newer $newest -not -path '*/\.*' -exec ln -sf {} newest.html \; # this is supposed to print the URLs in the indicated anchor text. sed -ne '/href=/{s/^.*href=\([^>]*\)>.*$/\1/; p; }' *.html set newest = `sed -ne 's/^.*URL=\([^"]*\)".*$/\1/; p; ' newest.html` find . -follow \( -path '*/noshow/' -prune \) -o -name '*\.*htm*' -type f -newer $newest -not -name 'newest.html' -not -path '*/\.*' -exec ./replaceinnewest \{\} \; replaceinnewest set newest = `sed -ne 's/^.*URL=\([^"]*\)".*$/\1/; p; ' newest.html` set newest = `findnewest $newest` echo $1 echo 'one moment, please...' > newest.html findnewest find . -follow \( -path '*/noshow/' -prune \) -o -name '*\.*htm*' -type f -newer $1 -not -name 'newest.html' -not -path '*/\.*' -exec ./replaceinnewest \{\} \; current version set newest=`sed -ne 's/^.*URL=\([^"]*\)".*$/\1/; p; ' newest.html` echo $newest find . -follow \( -path '*/noshow/' -prune \) -o -name '*\.*htm*' -type f -newer $newest -not -name 'newest.html' -not -path '*/\.*' -print -exec ./replaceinnewest \{\} \; This doesn't set the variable "newest". though the first set command does work from the command line. When executed from the command line, each call results in replacing the filenename in newest.html by a newer file. But it must be called several times to be sure to get the newest file. I tried to make an iterative version above, but I can't figure out how to detect whether find never succeeds. I also can't make find stop after the first success.