#!/bin/bash cd "$(dirname "$0")"; ( cat < Games HEREDOC for index in */index.html; do game="$(basename "$(dirname "$index")")"; ( head -n5 "$index" | tr -d '\n '; echo -n ""; ) tail -n5 "$index" | tr -d '\n '; ) > "$game.html"; echo " $game
" done; cat < HEREDOC ) > "index.html";