BASH : how to act based on test against a range of numbers
alright, I can set a file or a variable with a range of numbers...
for example: (either way is fine by me) Code:
$ cat range.txt Code:
$ echo $TEST for example, (using static numbers for example, and keeping in mind that $TEST is 77 in this example) Quote:
Quote:
|
Code:
test="77"; range=($(cat range.txt)); for i in $(seq 0 $[${#range[@]}-1]); do |
Code:
(while read && [[ $REPLY -lt $(( $test + 1 )) ]]; do true; done; echo "\"$REPLY\" is the first number greater than $test or the last line." ) < range.txt Code:
while true; do (break); done Code:
test="77"; range=($(cat range.txt)); for i in $(seq 0 $[${#range[@]}-1]); do |
Thanks for cleaning up again spirit receiver. I would prefer this below over "&&" since I'm not interested if echo fails or not, but that would be even less then trivial:
Code:
[ "${range[$i]}" -gt "$test" ] && { echo "running command"; break; }; done |
Quote:
|
All times are GMT -5. The time now is 05:02 PM. |