echo "Please enter four numbers: \c"
for i in 1 2 3 4
[ $number -gt $max ] && max=$number
echo "The maximum is: $max"
When I run it, for example, I type 1 2 3 4 and it does nothing...
on 04/30/2012 – Made popular on 04/30/2012
I am trying to calculate the maximum number from four numbers input by the user. I have the following code, but it does not work. It says there's an error with the last line "done". Any help would be appreciated.
Hello there, I am posting to seek help with a KSH script,
I am making a simple calculation program where the user can enter as many numbers as they like, I am getting their input using the read command, however I am not sure how to repeat doing this and storing the input in to new variables until the user wants the program to calculate.
I've been working on a few scripts and have been getting great info.
How, would I include in the below script, how I would let a user know that if they divide a SECOND number by zero, that they would get a divide by zero error? What's the easiest way of working this?
I think I asked this and didn't get a viable answer before. 'Trying again.
I've been working with C trying to get factorials which I've successfully accomplished but my code needs to output an error message when inputting negative numbers, unfortunately my code outputs an error when using 1 and 0.
This is what my code looks like (keep in mind I'm a beginner user so my code is simple).