I want a quick way to open the last modified file in the directory, perhaps in a form of alias.
Currently, I do ls -ltr. Then copy-and-paste the filename
Assume that I am using tcsh
To find last day modified files, you can also use the mtime command together with find. By specifying the option 0 as in the example below, mtime will return all files modified in the last 24 hours.
find . -type f -mtime -90 finds files that were modified in the last 90 days (or in the future). find . -type f -mtime +90 finds files that were modified at least 91 days ago (at least in POSIX compliant find implementations).
Switching Files from vi. Since switching back to the previous file is something that tends to happen a lot, you don't have to move to the ex command line to do it. The vi command ^^ (the "control" key with the caret key) will do this for you.
-mtime n is an expression that finds the files and directories that have been modified exactly n days ago. In addition, the expression can be used in two other ways: -mtime +n = finds the files and directories modified more than n days ago. -mtime -n = finds the files and directories modified less than n days ago.
vi `ls -tr | tail -1`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With