标签: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 循环数组
原文地址:http://silencezone.blog.51cto.com/3613477/1926448