繁体   English   中英

在 awk 中的每一行打印索引

[英]print Index with each line in awk

select 第一次显示选项并且它工作正常但是当我从 screenTwo function 进入这个菜单(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 的返回,每当它中断时使用 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

谢谢

这就是我为处理它所做的。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM