第一次选择显示选项并且它工作正常但是当我从screenTwo功能进入此菜单(previuos)时它会询问我选择但不显示选项,我该如何处理?
PS3="Please make a selection => " ; export PS3
select var in `awk -F "#" '{print $4}' ${Temp_Config_File} | uniq` PREVIOUS
do
echo "\n`date +"%d%m%Y%H%M%S"` Daemon $var selected " >> $Log_File
if [ -z $var ] ; then echo "\n\tPlease enter a valid choice \n " ; continue
else
if [ $var = "PREVIOUS" ]; then
#removeFiles
break
fi
screenTwo $var
fi
done
第一种选择:请给我你的想法。
第二个选项:捕获screenTwo的返回值 break使用awk以$ 4打印索引。 (如下所示,但我不喜欢 喜欢它)
if [ $breakStat -eq 99 ]; then
i=1
echo "\n\nPlease choose one of the following deamon you wish to Start/Stop\n\n"
awk -F "#" '{print $4}' Temp_OPDaemon_Config.cfg | uniq | while read line
do
echo "${i}) ${line}"
let i=i+1
done
echo "${i}) PREVIOUS"
fi
由于
答案 0 :(得分:1)
这就是我采取的措施。
PS3="Please make a selection => " ; export PS3
select var in `awk -F "#" '{print $4}' ${Temp_Config_File} | uniq` PREVIOUS
do
echo "${Date_Time} Daemon $var selected \n" >> $Log_File
if [ -z $var ] ; then echo "\n\tPlease enter a valid choice \n " ; continue
else
if [ $var = "PREVIOUS" ]; then
#removeFiles
break
fi
while :
do
screenTwo $var
breakStat=$?
if [ $breakStat -eq 99 ]; then
break
elif [ $breakStat -eq 98 ]; then
continue
fi
done
if [ $breakStat -eq 99 ]; then
echo "\n\nPlease choose one of the following deamon you wish to Start/Stop\n\n"
awk -F "#" '{print $4 }' ${Temp_Config_File} | uniq | awk -F "#" '{print NR ") " $0} END {print NR+1") PREVIOUS"}'
fi
fi
done