我正在尝试让我的终端返回最新的.txt文件,路径保持不变。我一直在研究ls、grep、find和tail,使用'|‘功能将结果从一个实用程序传递到另一个实用程序。最终结果将是一个工作路径+结果,我可以通过我的文本编辑器。
我已经接近了这样的测试: find。| grep '.txt$‘| tail -1
..but我没有用grep返回最新的文件--有没有遗漏什么标志?
尝试使用find & ls也不是很有效:
查找。-name "*.txt“| ls -lrth
..the ls返回当前目录,而不是查找查询的结果。
请帮帮我!
发布于 2011-06-11 03:25:02
如果你有bash4+
ls -t ./**/*.txt | head -1编辑最新的txt文件
vim $(ls -t ./**/*.txt |head -1)ps:需要在.bashrc或.profile中启用shopt -s globstar ...
https://stackoverflow.com/questions/6310849
复制相似问题