append to variable to search works

This commit is contained in:
Heavybullets8 2022-08-10 17:09:30 -06:00
parent dc5fd00681
commit 1949c2100c

View File

@ -45,17 +45,20 @@ else
do do
clear -x clear -x
title title
cont_search=$(
for container in "${containers[@]}" for container in "${containers[@]}"
do do
echo "$container" echo "$container"
done | nl -s ") " | column -t done | nl -s ") " | column -t
)
echo "$cont_search"
echo echo
echo "0) Exit" echo "0) Exit"
read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
if [[ $selection == 0 ]]; then if [[ $selection == 0 ]]; then
echo "Exiting.." echo "Exiting.."
exit exit
elif ! echo -e "${containers[@]}" | nl -s ") " | grep -qs ^"$selection)" ; then elif ! echo -e "$cont_search}" | nl -s ") " | grep -qs ^"$selection)" ; then
echo "Error: \"$selection\" was not an option.. Try again" echo "Error: \"$selection\" was not an option.. Try again"
sleep 3 sleep 3
continue continue
@ -63,7 +66,7 @@ else
break break
fi fi
done done
container=$(echo "${containers[*]}" | grep ^"$selection)" | awk '{print $2}') container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}')
container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}')
fi fi
while true while true