How to open the last edited file

OpenSource For You - - TIPS & TRICKS - —Suren­dra Patil, [email protected]

To open the last edited file in the cur­rent di­rec­tory, use the com­bi­na­tion of the ls, head and vi com­mands as shown be­low.

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 fol­low­ing com­mand to open the last edited file:

$ vim `ls -t | head -1` Here, ls -t sorts the file based on the time of mod­i­fi­ca­tion, show­ing the last edited file first. head ­1 picks up this first file and opens it in the vim text ed­i­tor.

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.