bash 使用 vi 打开目录中最后修改的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2066636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
open last modified file in the directory using vi
提问by vehomzzz
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
目前,我做 ls -ltr。然后复制并粘贴文件名
Assume that I am using tcsh
假设我正在使用 tcsh
回答by GJ.
vi `ls -tr | tail -1`
回答by Subhash
Creating an alias for the mentioned answer will avoid typing the command every time.
为上述答案创建别名将避免每次都键入命令。
Add below entry in .tcshrcfile and reload.
在.tcshrc文件中添加以下条目并重新加载。
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` ; -'

