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