標籤:shell 迴圈數組
aa="contrib/fatjar/conf
contrib/loggraph
contrib/loggraph/src
contrib/loggraph/src/java
contrib/loggraph/src/java/org
contrib/loggraph/src/java/org/apache
contrib/loggraph/src/java/org/apache/zookeeper
contrib/loggraph/src/java/org/apache/zookeeper/graph
contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets
contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops
contrib/fatjar"
array=(`echo ${aa}|tr "\n" " "`)
for ((i=0;i<${#array[*]};i++))
do
echo "mkdir -p \$RPM_BUILD_ROOT/opt/zookeeper/${array[$i]}"
done
—————————————————————————————————————————————列印出的結果:
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/fatjar/conf
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src/java
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src/java/org
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src/java/org/apache
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src/java/org/apache/zookeeper
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src/java/org/apache/zookeeper/graph
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops
mkdir -p $RPM_BUILD_ROOT/opt/zookeeper/contrib/fatjar
本文出自 “silence” 部落格,請務必保留此出處http://silencezone.blog.51cto.com/3613477/1926448
shell 指令碼-----迴圈數組