Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 如何通过部分匹配文件名在VS代码终端中打开文件?_Bash_Terminal_Visual Studio Code - Fatal编程技术网

Bash 如何通过部分匹配文件名在VS代码终端中打开文件?

Bash 如何通过部分匹配文件名在VS代码终端中打开文件?,bash,terminal,visual-studio-code,Bash,Terminal,Visual Studio Code,如果我有一个名为w5\u align\u example.cpp的文件,我如何仅通过提供单词align在VS代码集成终端中打开该文件 code w5\u align\u sample.cpp会打开它,但有时我只记得关键字align,除非我在单独的命令中搜索以查看文件的开头。我想在一个命令中打开 我试过: $ls | grep“align”| code这使我可以使用“code-”运行以读取另一个程序的输出(例如“echo Hello World | code-”)。错误 $ls | grep“a

如果我有一个名为
w5\u align\u example.cpp
的文件,我如何仅通过提供单词
align
在VS代码集成终端中打开该文件

code w5\u align\u sample.cpp
会打开它,但有时我只记得关键字
align
,除非我在单独的命令中搜索以查看文件的开头。我想在一个命令中打开

我试过:

  • $ls | grep“align”| code
    这使我可以使用“code-”运行
    以读取另一个程序的输出(例如“echo Hello World | code-”)。
    错误

  • $ls | grep“align”| code-
    打开一个名为
    code stdin sfd.txt
    的新文件,其中包含文本
    w5_align\u example.cpp

最简单(即最短)的命令是什么

ls | grep "align" | xargs -I{} code {}


您只需使用
*
。它匹配任何字符串,可以多次使用

code *align*
在某些Shell中,您可以将其与制表符完成结合使用。仅键入:

code *align*
然后按Tab键。这将填充文件名的其余部分,但如果有多个选项,则会发出嘟嘟声

code *align*