Skip to content

Instantly share code, notes, and snippets.

@hugot
Created February 13, 2017 22:32
Show Gist options
  • Save hugot/84e91e3795dba48b96a2f8bdb3fd962f to your computer and use it in GitHub Desktop.
Save hugot/84e91e3795dba48b96a2f8bdb3fd962f to your computer and use it in GitHub Desktop.
another python tutorial in bash :)
#!/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
@hugot
Copy link
Author

hugot commented Feb 13, 2017

I mad this script inspired by this python tutorial http://www.practicepython.org/exercise/2014/02/15/03-list-less-than-ten.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment