Print file lines from the end to the top to inspect recent events quickly. 11.05.2026 | reading time: 2 min Want to examine a log from newest entry to oldest? Use `tac` to print a file one line at a time starting at the end; it is a tiny, focused tool that reverses line order and fits neatly into pipes and scripts. Reverse a log file in seconds Try this: create a small sample and run `tac` to see the effect. ``` $ printf "one\ntwo\nthree\n" > sample.txt $ tac sample.txt three two one ``` The output shows the file printed from last line to first, which is handy when the newest entries appear at the bottom of a log. Options to shape output `tac` is simple but flexible: use `-s` to set a custom separator, `-b` to place the separator before instead of after matched blocks, `-r` to treat the separator as a regular expression and `-z` for NUL-terminated records; combine it with pipes to filter or reformat reversed data quickly. When to pick something else For per-line character reversal use `rev`; for complex extraction or reordering use `sed` or `awk`; on some BSD systems `tail -r` provides similar reversed output behavior, so choose the tool that best fits the surrounding pipeline and portability needs. Next step Practice by reversing real logs and chaining `tac` with `sed` or `awk` to extract recent events, then explore deeper shell scripting techniques; consider formalizing that knowledge with certifications like CompTIA Linux+ or LPIC-1 and intensive exam preparation at bitsandbytes.academy to accelerate progress. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting