open last modified file in the directory using vi

别说谁变了你拦得住时间么 提交于 2019-12-20 20:30:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!