如何将 ls 重定向到 cd 命令

Vas*_*ska 2 bash ls

我想做ls | grep somethingcd列出的一件事。我尝试|和搜索,但没有找到。它在使用xargs吗?

And*_*rew 5

你可以做

$ cd $( ls | grep foo )
Run Code Online (Sandbox Code Playgroud)

但这只有在结果与您当前所在的位置相关时才有效;对于您想要的更多内容find(它将打印路径)和非常具体的grep模式。