#! /bin/sed -f # Reverse a line; add a new-line to the end s/$/\ / # Move first character at the end. The regexp matches # until the first character has become the new-line tx :x s/\(.\)\(.*\n\)\(.*\)/\2\1\3/ tx # Remove the new-line s/^.//