# Output the most recent blog entries # Blog entries must be named in the format YYYYMMDD##.html # Where YYYY is between 2000 and 2999 # and ## is an ordinal of some kind # NOTE: Script breaks after Dec 31, 2999 # How many entries do you want? howmany=10 # What's the value of today's date? today=`date +%Y%m%d` # What's our file set? catalog=(`ls -r 2*.html`) # Create the file list for entry in ${catalog[@]} ; do # if it's from today or earlier, add it to the list if [ ${entry:0:8} -le ${today} ] ; then recent=(${recent[@]} ${entry}) ; fi # if the list is full, stop adding if [ ${#recent[@]} -eq $howmany ] ; then break ; fi done # Output recent entries for file in ${recent[@]} ; do cat $file ; # add the file echo '
' ; # insert a break & clear echo # insert a blank line echo '
' ; # insert a break & clear echo # insert a blank line done