#!/bin/bash a=`ls /data1/chenggang5/kepler/cases` cat <<EOF `j=0;for i in $a;do let j=$j+1;if [ $((j%5)) -ne 0 ];then print=\`printf "%-21s " $i\`;echo -n -e "e[1;32m $print e[0m";else print=\`printf "%-21s" $i\`;echo -e "e[1;32m $print e[0m";fi; done` EOF while [ 0 ] do echo -n -e "e[1;33m【请选择要执行的案例,如输入03,输入all,则执行全部案例,输入q或e,则退出程序】:e[0m" read input for i in $a do w=`echo $i|awk -F. '{print $1}'` x=`echo $i|awk -F. '{print $0}'` case $input in $w) sh ../bin/run.sh cases/$x esac done case $input in all) sh ../bin/run.sh cases ;; q) exit;; Q) exit;; e) exit;; E) exit;; esac done
命令详解:
cat <<EOF
EOF
控制多行输出
`j=0;for i in $a;do let j=$j+1;if [ $((j%5)) -ne 0 ];then print=\`printf "%-21s " $i\`;echo -n -e "e[1;32m $print e[0m";else print=\`printf "%-21s" $i\`;echo -e "e[1;32m $print e[0m";fi; done`
这一行主要是 规定每行的输出列数,并对其进行颜色设置
while [ 0 ] 控制循环;read 读取键盘输入;case 进行选择
效果图如下: