1. 程式人生 > 其它 >shell指令碼-迴圈遍歷陣列並執行_v1.0.0

shell指令碼-迴圈遍歷陣列並執行_v1.0.0

技術標籤:技術棧-語言-Shellshell陣列遍歷格式轉換linux指令碼

v1.0.0

  1. 指令碼
    【請注意】上linux server後執行命令:dos2unix test.sh 之後再執行:sh test.sh
#! /bin/bash
# 【請注意】上linux server後執行命令:dos2unix test.sh 之後再執行:sh test.sh

APP_NAME=("job-admin" "great-auth" "大羅金仙" "great-form" "great-portal"
"great-system" "使用者" "great-ureport" "sc-gateway") # =號左右不能有空格 for item in ${APP_NAME[@]} # 不需要分號 do echo $item # 注意加上$ done
  1. 執行
yum -y install dos2unix
dos2unix test.sh
sh test.sh
  1. 輸出
    在這裡插入圖片描述
job-admin
great-auth
大羅金仙
great-form
great-portal
great-system
使用者
great-ureport
sc-gateway