码迷,mamicode.com
首页 > 编程语言 > 详细

shell 脚本-----循环数组

时间:2017-05-17 10:18:01      阅读:174      评论:0      收藏:0      [点我收藏+]

标签: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 脚本-----循环数组

标签:shell 循环数组

原文地址:http://silencezone.blog.51cto.com/3613477/1926448

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!