ここからは、さまざまなUnixコマンドをまねる、まったく役に立たない(けれども興味深い)スクリプトが続きます。これは、その中でもtacと同じように動くスクリプトです。
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
2行目からは、それまでのすべての行を含むバッファーを現在の行の後に追加するため、順序が逆になります。
# on the last line we're done -- print everything $ p
最終行で処理を終え、すべてを出力します。
# store everything on the buffer again h
すべてを再びバッファーに格納します。