shell 脚本-----循环数组
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 脚本-----循环数组的主要内容,如果未能解决你的问题,请参考以下文章