Photo by Paolo Chiabrando / Unsplash

Recent Events

tiny tool Oct 21, 2025 (Oct 21, 2025) Loading...

I wanted to see the most-recent entries of the most-recent logs.

ls -1td /var/log/*.log | head -3 | xargs -I {} sh -c 'tail -10 "{}"'

This uses:

  • ls to make a list of files (with paths) sorted by recency
  • head to clip the top 3
  • xargs to run those three into tail to pick up the bottom 10 lines.

Wrinkle 1 – listing with the paths means xargs doesn't need to be passes the path of the files.

Wrinkle 2 – {} is something uncommon to use as a pattern – no more. But it's a common pair to use, when finding things to sub for in commandline things. Presumably no use in javascript code...

This alternative separates the logs – easier to use.

ls -1td /var/log/*.log | head -3 | xargs -I {} sh -c 'echo "=== {} ==="; tail -10 "{}"'

Member reactions

Reactions are loading...

Sign in to leave reactions on posts

Tags

Comments

Sign in or become a Workroom Productions member to read and leave comments.

James Lyndsay

Getting better at software testing. Singing in Bulgarian. Staying in. Going out. Listening. Talking. Writing. Making.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.