如何使“选择”在单列中显示选项?

Pet*_*etr 4 linux bash select

我有一个随机情况,当我在 bash 中使用多项选择菜单并向我的列表选择添加更多项目时,菜单不再逐行堆叠

echo "         [?] What would you like to do:"
echo
# End

opt=""
select recon in Enumeration General Web-Recon Services Msfvenom Other
do
opt="$recon"
case $recon in 
Enumeration|General|Web-Recon|Services|Msfvenon|Other)   
        break
        ;;
*)
        echo # Spacer
        echo "You Sure? Try it again" 
        ;;
esac
echo $recon
done
Run Code Online (Sandbox Code Playgroud)

我得到的看起来像这样:

         [?] What would you like to do:

1) Enumeration  3) Web-Recon    5) Msfvenom
2) General      4) Services     6) Other
#? 
Run Code Online (Sandbox Code Playgroud)

但是我更喜欢它看起来像这样:

1) Enumeration
2) General  
3) Web-Recon
4) Services 
5) Msfvenom             
6) Other
Run Code Online (Sandbox Code Playgroud)

有没有办法告诉脚本这样做?谢谢

Cyr*_*rus 6

COLUMNS=0在您的select命令之前使用。

用 bash 4.2.8 测试。

  • 它对我不起作用。但是,如果我使用 COLUMNS=1,它就会起作用。奇怪。 (4认同)