Between the kitten question and seeing this question at U&L about some sed
magic, how about implementing tac
?
Objective
Implement a program that will reverse and print the lines in a file.
Input
A file, provided as a name or via standard input
Output
The lines, reversed, to standard out.
Scoring
Bytes of source code.
tac
is a bit strange when it comes to trailing linefeeds. It transformsa\nb\n
(trailing linefeed) intob\na\n
anda\nb
(no trailing linefeed) intoba\n
. Is this how our code it supposed to behave? \$\endgroup\$tac
is only a matter of time... \$\endgroup\$\n
.tac
reverses the order of these rows. If an\n
is removed from the middle of the file, the row it terminated is joined to the next row, but in the case of the last line, there is no next row to join to. \$\endgroup\$