26 lines
506 B
Sed
26 lines
506 B
Sed
|
|
#!/bin/sed -f
|
||
|
|
|
||
|
|
# reverse_characters_debug.sed
|
||
|
|
#
|
||
|
|
# A version which prints what it's doing to help understand the process
|
||
|
|
|
||
|
|
/../! b
|
||
|
|
|
||
|
|
# Reverse a line. Begin embedding the line between two newlines
|
||
|
|
s/^.*$/\n&\n/
|
||
|
|
|
||
|
|
# List the line to see what the command above did to it
|
||
|
|
l
|
||
|
|
|
||
|
|
# Move first character at the end. The regexp matches until
|
||
|
|
# there are zero or one characters between the markers
|
||
|
|
tx
|
||
|
|
:x
|
||
|
|
s/\(\n.\)\(.*\)\(.\n\)/\3\2\1/
|
||
|
|
# List the result of each loop iteration
|
||
|
|
l
|
||
|
|
tx
|
||
|
|
|
||
|
|
# Remove the newline markers
|
||
|
|
s/\n//g
|