代码之家  ›  专栏  ›  技术社区  ›  Ben

bash脚本中的VSCode CLI while循环打开多个文件

  •  0
  • Ben  · 技术社区  · 11 月前

    我正在尝试使用VSCode cli code 在一个 while 在Bash脚本中循环以打开多个文件,我正在从文本文件中读取这些文件的名称。

    当我运行下面的代码时,它会正确打开我正在读取的文件的第一行,然后打开一个类似的文件 code-stdin-XXX 这是来自的其余行的列表 filenames.txt 如果我改变 代码 echo 在脚本中,这运行得很好,所以我认为我遗漏了一些东西 代码 cli选项。

    while read -r line ; do
        code - "../songs/$line.xhtml"
    done < filenames.txt
    

    我如何正确地得到 代码 打开每行的文件 文件名.txt ?

    1 回复  |  直到 11 月前
        1
  •  1
  •   Dustin Bounty Hunter    11 月前
    for line in $(cat filenames.txt); do
        code "../songs/$line.xhtml"
    done