function greater {
grep -Eo '[0-9]*' $1 | sort -rn | head -n 1
}
function lesser {
grep -Eo '\-[0-9]*' $1 | sort -n | head -n 1
}
I've made these functions, but the negative numbers are being printed: the first function is ignoring the - sign, so it is showing the greatest number, but it should print the greatest positive. Any ideas on how to solve that?
Sample input:
-100 -90 95
10 -20
500 400 300 200 600
Sample output:
Greater: 600
Lesser: -100
(The lesser is working perfectly.)