Created
October 17, 2011 02:01
-
-
Save adamesque/1291770 to your computer and use it in GitHub Desktop.
Bash alias to get the last modified file in a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Naive NOT-FOR-PRODUCTION method. Fails for filenames that contain newlines. | |
| alias lastmod="ls -t | head -n 1" |
Author
since you're writing the file names, this probably won't be a big deal, but you may want to read this: http://mywiki.wooledge.org/ParsingLs
Author
Ha! You know, I really ought to know better; I fixed that exact same bug in node: nodejs/node-v0.x-archive@7f30f13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ls -t: List the files in the directory sorted by mod datehead -n 1: Print the first1line of the input (default is 10)I'm working through the K&R book, keeping all the examples and exercises in separate files. I use this to make it easier to compile whichever source file I most recently touched:
cclastmod``, because I am extremely lazy.