#!/bin/sh function gen_redirect { TARGET_URL="$1" cat < Page has moved! — GNU Guix Redirecting to the new page location... EOF } URL_PREFIX="/software/guix/" for page in "$@" do page_without_extension="`echo $page | sed -es'/\.html$//g'`" new_page="`find ../blog -name $page_without_extension -type d | head -1`" if [ -z "$new_page" ] then echo "no new page for '$page'" >&2 exit 1 fi # Strip '../'. new_page_url="$URL_PREFIX`echo $new_page | cut -c 4-`" echo "redirect '$page' -> '$new_page_url'" gen_redirect "$new_page_url" > "$page".new && mv "$page".new "$page" done