Created
February 13, 2017 22:32
-
-
Save hugot/84e91e3795dba48b96a2f8bdb3fd962f to your computer and use it in GitHub Desktop.
another python tutorial in bash :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#This script asks the user to provide a number and then compares that number to the numbers in an array | |
array=(1 2 3 4 5 6 7 8 9 10 11 12 13 14) | |
otherArray=() | |
echo please provide a number to compare | |
read number | |
for ((i=0; i<${#array[@]}; i++)); do | |
[[ "${array[$i]}" -lt "$number" ]] && otherArray[${#otherArray[@]}]=${array[$i]} | |
done | |
echo The numbers "${otherArray[*]}" are smaller than your number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I mad this script inspired by this python tutorial http://www.practicepython.org/exercise/2014/02/15/03-list-less-than-ten.html