开发者

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` ; -'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜