From 9f7599f7b4a799d2d508a999cbdbd26ba8213a31 Mon Sep 17 00:00:00 2001 From: fanta Date: Wed, 5 Oct 2022 15:31:14 +0200 Subject: [PATCH] =?UTF-8?q?n=C3=BAmeros=20validos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q b/q index 80c59eb..6fa707d 100755 --- a/q +++ b/q @@ -14,12 +14,19 @@ function downloadSysList(){ } function filterList(){ + nl=$(cat /home/fanta/vms/.systems.lst | wc -l) cat -n $vmsDir/.systems.lst | cut -d ";" -f 1,2 | tr ";" " " echo " " read -p "Number: " option if [[ $option == ?(-)+([0-9]) ]] ; then - cat $vmsDir/.systems.lst | head -$option | tail -1 > $vmsDir/.systems2.lst - mv $vmsDir/.systems2.lst $vmsDir/.systems.lst + if [ "$option" -ge 1 ] && [ "$option" -le $nl ]; then + cat $vmsDir/.systems.lst | head -$option | tail -1 > $vmsDir/.systems2.lst + mv $vmsDir/.systems2.lst $vmsDir/.systems.lst + else + echo -e "\nError: Try again and enter a valid number my friend" + exit + fi + else echo -e "\nError: Try again and enter a integer number my friend" exit