嵌套的for循环中的命令和变量

时间:2020-02-04 04:28:13

标签: linux bash docker loops scope

我正在尝试在嵌套的for循环内进行迭代的skopeo复制。该命令无法识别我在循环内设置的变量。我尝试过:


for i in list_files.txt; do
  image_name=$(cat list_files.txt | sed -e 's/\-[^*]*$//')
  for i in list_files.txt; do
    version=$(cat list_files.txt | sed -e 's/[^0-9.]*//' | sed 's/.tar//')
    tar_name=$(cat list_files.txt)

    skopeo copy \
      docker-archive:/opt/app-root/src/$tar_name \
      docker://private/dsop/test/$image_name:$version \
      --dest-creds=$USERNAME:$PASSWORD \
      --dest-tls-verify=false
  done
done

为什么我不能使用设置的变量?

我收到错误消息:

FATA[0000] Exactly two arguments expected

0 个答案:

没有答案