小编Via*_* On的帖子

如何在 Linux makefile 中初始化然后迭代数组?

我需要创建一个包含目录的数组,然后对其进行 inerate,在每个步骤中再创建一个数组,其中将包括通过每个 derictory 的“find”命令找到的所有文件,并迭代该数组。我试图做这样的事情:

declare -a arr=(a b c) ;\
for key in "$${arr[@]}" ; do \
    ...
  done\
Run Code Online (Sandbox Code Playgroud)

但它不起作用。即使这样也会出错:

all:
        declare -a array=(a b c) ;\
        echo "$${array[1]}" \
Run Code Online (Sandbox Code Playgroud)

得到错误:

/bin/sh: 1: Syntax error: "(" unexpected
Makefile:4: recipe for target 'gg' failed
make: *** [gg] Error 2
Run Code Online (Sandbox Code Playgroud)

unix linux makefile gnu-make

3
推荐指数
1
解决办法
2880
查看次数

标签 统计

gnu-make ×1

linux ×1

makefile ×1

unix ×1