Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open last modified file in the directory using vi

Tags:

bash

vi

tcsh

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

like image 536
vehomzzz Avatar asked Jan 14 '10 18:01

vehomzzz


People also ask

How do I find the latest modified file in Unix?

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.

How do I find recently modified files in Linux?

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).

How do I go to a previous file in vi editor?

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.

How do I find the last modified directory in Linux?

-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.


1 Answers

vi `ls -tr | tail -1`
like image 112
GJ. Avatar answered Oct 26 '22 03:10

GJ.