shell指令碼-迴圈遍歷陣列並執行_v1.0.0
阿新 • • 發佈:2021-01-10
技術標籤:技術棧-語言-Shellshell陣列遍歷格式轉換linux指令碼
v1.0.0
- 指令碼
【請注意】上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
- 執行
yum -y install dos2unix
dos2unix test.sh
sh test.sh
- 輸出
job-admin great-auth 大羅金仙 great-form great-portal great-system 使用者 great-ureport sc-gateway