Suppose you have edited last three following files using vi
user1@localhost$ vi file1.txt
user1@localhost$ vi file2.txt
user1@localhost$ vi file3.txt
Now to open the last edited file command is
user1@localhost$ vi ls -t | head -1
Here ls -t sort the file in order of last modified file and head -1 picks up the first file.
So here the output of the command executed above will be file1.txt file will be opened in vi for editing.
user1@localhost$ vi file1.txt
user1@localhost$ vi file2.txt
user1@localhost$ vi file3.txt
Now to open the last edited file command is
user1@localhost$ vi ls -t | head -1
Here ls -t sort the file in order of last modified file and head -1 picks up the first file.
So here the output of the command executed above will be file1.txt file will be opened in vi for editing.
No comments:
Post a Comment