OpenSource For You

How to open the last edited file

- —Surendra Patil, suru47@gmail.com

To open the last edited file in the current directory, use the combinatio­n of the ls, head and vi commands as shown below.

Open file 1 and make changes.

$ vim file1 Save and close the file. Now open file 2 and make changes.

$ vim file2 Save and close the file. Next, run the following command to open the last edited file:

$ vim `ls -t | head -1` Here, ls -t sorts the file based on the time of modificati­on, showing the last edited file first. head 1 picks up this first file and opens it in the vim text editor.

 ??  ??

Newspapers in English

Newspapers from India