次: cat -n, 前: Reverse chars of lines, 上: Examples
以下のものは,様々なUnixコマンドをエミュレートする全く意味がない(面白い
けどね)スクリプトです.これは特にtacと同等の動作をします.
GNU sedとGNU sed以外の実装では, このスクリプトは簡単に内部バッファでオーバーフローする可能性があること に注意してください.
#!/usr/bin/sed -nf
# reverse all lines of input, i.e. first line became last, ...
# from the second line, the buffer (which contains all previous lines)
# is *appended* to current line, so, the order will be reversed
1! G
# on the last line we're done -- print everything
$ p
# store everything on the buffer again
h