问题
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
回答1:
vi `ls -tr | tail -1`
回答2:
Creating an alias for the mentioned answer will avoid typing the command every time.
Add below entry in .tcshrc
file and reload.
alias v='vi `ls -tr | tail -1`'
To avoid going to log folder and executing the command, create below alias and reload.
alias -- -='cd -'
alias v='cd /path/to/log/folder; vi `ls -tr | tail -1` ; -'
来源:https://stackoverflow.com/questions/2066636/open-last-modified-file-in-the-directory-using-vi