Demos: Removing trailing whitespace and double blank lines

TMPFILE=$( mktemp ); find demos -type f | while read; do cat "$REPLY" | sed 's/[ \t]*$//' | awk -v 'lastWasBlank=0' '{if ( 0 == lastWasBlank ) print; if ( $0 == "" ) lastWasBlank = 1; else { if ( lastWasBlank ) print; lastWasBlank = 0; }}' > "$TMPFILE" && mv "$TMPFILE" "$REPLY"; done; rm -f "$TMPFILE";