我正在写一个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
原来有人将alias ls=ls --color
添加到此服务器的bashrc中。删除别名后,我的功能才起作用。 - 丹尼尔谭