我正在运行以下命令:
cd $(find /tmp/my_temp/ -type d -wholename '/tmp/my_temp/MyNumb-*_WeCo - MX')
它返回这样的东西:
/tmp/nolio_temp/MyNumb-15_WeCo - MX
当尝试 cd
到这个输出时我不能,因为有空格。
有什么方法可以cd
到find
返回的目录,即使存在空格?
最佳答案
只要引用它就可以了:
cd "$()"
在你的情况下:
cd "$(find /tmp/my_temp/ -type d -wholename '/tmp/my_temp/MyNumb-*_WeCo - MX')"
通过这种方式,您可以告诉 cd
使用双引号中的内容作为参数。
关于linux - chdir 到带空格的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28907783/