更改for循环打印菜单逻辑

This commit is contained in:
lsy 2024-09-21 16:07:27 +08:00
parent 03c4d2fede
commit f7c057fb78

6
Run.sh
View File

@ -14,14 +14,12 @@ do
pick_number=0 pick_number=0
echo "======Linux工具箱======" echo "======Linux工具箱======"
cd Menus || exit for i in "${PWD}/Menus/"*
for i in *
do do
pick_number=$((pick_number + 1)) pick_number=$((pick_number + 1))
pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$i") pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
echo "${pick_number}.${pick_array[$pick_number]}" echo "${pick_number}.${pick_array[$pick_number]}"
done done
cd - >> /dev/null
echo "======Linux工具箱======" echo "======Linux工具箱======"
read -p "请输入要使用的功能:" pick read -p "请输入要使用的功能:" pick
if [[ "${pick}" -gt 0 && "${pick}" -le "${#pick_array[*]}" ]];then if [[ "${pick}" -gt 0 && "${pick}" -le "${#pick_array[*]}" ]];then