使用 vi 打开目录中最后修改的文件

发布于 2024-08-17 20:40:28 字数 95 浏览 4 评论 0原文

我想要一种快速的方法来打开目录中最后修改的文件,也许以别名的形式。

目前,我执行 ls -ltr。然后复制并粘贴文件名

假设我使用的是 tcsh

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深巷少女 2024-08-24 20:40:28
vi `ls -tr | tail -1`
vi `ls -tr | tail -1`
意中人 2024-08-24 20:40:28

为上述答案创建别名将避免每次都键入命令。

.tcshrc 文件中添加以下条目并重新加载。

alias v='vi `ls -tr | tail -1`'

为了避免进入日志文件夹并执行命令,请创建以下别名并重新加载。

alias -- -='cd -'
alias v='cd /path/to/log/folder; 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` ; -'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文