#!/bin/bash
#-- this script shows what books are available in the
#-- books folder and formats the output as html
base=/home/groups/b/bu/bumble/htdocs
#base=/home/matth3wbishop/sf/htdocs
echo ""
echo '
'
#---------------------------------------------
#find $base/books/ -name "*book.txt" | xargs wc -l | sort -rn | sed "s/ *[0-9]* *//" | egrep -v "/test|/format|total$")
# sort the books by the number of lines which each has
for i in $(find $base/books/ -name "*book.txt" | xargs wc -l | sort -rn | egrep -v "/test|/format|total$" | awk '$1 > 100 {print $2}')
do
title=$(sed -n '/^ *&&/{s/&&//g;p;q;}' $i)
lines=$(wc -l $i | sed "s/ .*$//")
recipes=$(grep "^ *\*" $i | wc -l)
quality=$(sed -n '/^ *document-quality:/{s/^[^:]*: *//g;p;q;}' $i)
revised=$(sed -n '/^ *last-revision:/{s/^[^:]*: *//g;p;q;}' $i)
description=$(sed -n '/^ *short-description:/{s/^[^:]*: *//g;p;q;}' $i)
icon=$(sed -n '/^ *document-icon:/{s/^[^:]*: *//g;p;q;}' $i)
cat <$(test ! -z $icon && echo "")
$title
-
$description
- number of text lines: $lines
- number of "recipes": $recipes
- book quality: $quality
- last revised: $revised
html |
text |
latex |
pdf |
pdf (recompile)
eox
done
echo '
'
echo ''
# display the books which have less than 100 lines
for i in $(find $base/books/ -name "*book.txt" | xargs wc -l | sort -rn | egrep -v "/test|/format|total$" | awk '$1 < 101 {print $2}')
do
title=$(sed -n '/^ *&&/{s/&&//g;p;q;}' $i)
lines=$(wc -l $i | sed "s/ .*$//")
recipes=$(grep "^ *\*" $i | wc -l)
quality=$(sed -n '/^ *document-quality:/{s/^[^:]*: *//g;p;q;}' $i)
revised=$(sed -n '/^ *last-revision:/{s/^[^:]*: *//g;p;q;}' $i)
description=$(sed -n '/^ *short-description:/{s/^[^:]*: *//g;p;q;}' $i)
icon=$(sed -n '/^ *document-icon:/{s/^[^:]*: *//g;p;q;}' $i)
cat <$(test ! -z $icon && echo "")
$title
-
$description
html |
text |
latex |
pdf (beta)
eox
done
echo '
'