UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 16.26 Finding Text Files with findtext Chapter 16
Where Did I Put That?
Next: 16.28 oldlinks: Find Unconnected Symbolic Links
 

16.27 newer: Print the Name of the Newest File

Here's a quick alias that figures out which file in a group is the newest:

-d 
alias newer "ls -dt \!* | head -1"

csh_init
sh_init
If your system doesn't have a head (25.20) command, use sed 1q instead.

For example, let's say that you have two files named plan.v1 and and plan.v2. If you're like me, you (often) edit the wrong version by mistake - and then, a few hours later, can't remember what you did. You can use this alias to figure out which file you changed most recently:

* 
% newer plan.v*
plan.v1

Oops. I edited the wrong version by mistake. I could also have used backquotes (9.16) to handle this in one step:

% emacs `newer plan.*`

- ML


Previous: 16.26 Finding Text Files with findtext UNIX Power ToolsNext: 16.28 oldlinks: Find Unconnected Symbolic Links
16.26 Finding Text Files with findtext Book Index16.28 oldlinks: Find Unconnected Symbolic Links

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System