bash:cd:没有这样的文件或目录

问题描述 投票:0回答:1

我正在写一个bash函数来跳转到我上次编辑的文件夹。在我的示例中,最后编辑的文件夹名为“daniel”。

bash函数看起来很好。

>>:~$ echo $(ls -d -1dt -- */ | head -n 1)
daniel/

我可以手动cd进入目录。

>>:~$ cd daniel
>>:~/daniel$ 

但是我不能使用bash函数进入目录。

>>:~$ cd $(ls -d -1dt -- */ | head -n 1)
bash: cd: daniel/: No such file or directory
linux bash function alias ls
1个回答
0
投票

原来有人将alias ls=ls --color添加到此服务器的bashrc中。删除别名后,我的功能才起作用。 - 丹尼尔谭

© www.soinside.com 2019 - 2024. All rights reserved.