开发者

open last modified file in the directory using vi

开发者 https://www.devze.com 2022-12-17 12:28 出处:网络
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

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

精彩评论

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