Skip to main content
13 events
when toggle format what by license comment
Oct 3, 2021 at 3:07 comment added johnsyweb Yup. This 10-year-old answer was not written as a recommendation. tac was written for a reason.
Oct 1, 2021 at 19:50 comment added Ed Morton This would take orders of magnitude longer to run than the decorate (add line numbers) | sort (in reverse by line numbers) | undecorate (remove line numbers) solutions, unix.stackexchange.com/a/9357/133219 and unix.stackexchange.com/a/36191/133219.
Dec 30, 2020 at 20:32 history edited Kusalananda CC BY-SA 4.0
Fix quoting
Sep 14, 2012 at 5:48 comment added Stéphane Chazelas Note that tac is faster for regular files because it reads the file backward. For pipes, it has to do the same as the other solutions (hold in memory or in temp files), so is not significantly faster.
Aug 7, 2012 at 12:11 comment added Peter.O @Johnsyweb. Yes, so would I :) but the question and answers have served to highlight tac's amazing performance. tac is faster, by an order of magnitude, than the only other reliable answer cat -n | sort -nrk1 | cut -f2- .. The non-sort/non-tac methods run into critical memory problems for large files. Olympic gold for tac!
Aug 7, 2012 at 6:02 comment added johnsyweb @Peter: Personally I'd use tac.
Aug 6, 2012 at 17:08 comment added Peter.O This becomes impractically slow for not-small files... it basically grinds to halt ...
Apr 15, 2011 at 20:39 comment added Random832 So do all the other answers (except maybe the one using sort - there's a chance it will use a temporary file).
Mar 17, 2011 at 14:33 comment added Mr. Shickadance Perhaps worth noting: "These two one-liners actually use a lot of memory because they keep the whole file in hold buffer in reverse order before printing it out. Avoid these one-liners for large files."
Mar 16, 2011 at 13:15 history migrated from stackoverflow.com (revisions)
Mar 16, 2011 at 11:37 comment added johnsyweb It's a famous sed one-liner. See "36. Reverse order of lines (emulate "tac" Unix command)." in Famous Sed One-Liners Explained for a full explanation of how it works.
Mar 16, 2011 at 11:19 comment added Chen Levy This is a good solution, but some explanation for how this works will be even better.
Mar 16, 2011 at 10:59 history answered johnsyweb CC BY-SA 2.5