open last modified file in the directory using vi
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 开发者_运维问答
vi `ls -tr | tail -1`
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` ; -'
精彩评论