sed: tac

1 
1 7.9 Reverse Lines of Files
1 ==========================
1 
1 This one begins a series of totally useless (yet interesting) scripts
1 emulating various Unix commands.  This, in particular, is a 'tac'
1 workalike.
1 
1    Note that on implementations other than GNU 'sed' this script might
1 easily overflow internal buffers.
1 
1      #!/usr/bin/sed -nf
1 
1      # reverse all lines of input, i.e. first line became last, ...
1 
1      # from the second line, the buffer (which contains all previous lines)
1      # is *appended* to current line, so, the order will be reversed
1      1! G
1 
1      # on the last line we're done -- print everything
1      $ p
1 
1      # store everything on the buffer again
1      h
1