shell programming
i have to calculate mean value using shell programming.
ex: ./mean 11 15 18 19 41 45 but i cant succeed the getting arguments. The problem is count of arguments. I search web and see examples they are doing like that n1=$1 n2=$2 n3=$3 ... .. but in my situation, number of arguments is unknown i mean, there will be only two or one hundred arguments. how cant i get arguments in this situation? show me the rigth way thnx... |
Try using shift, described here
|
Code:
#!/bin/bash |
Here's something that will work.
Code:
#!/bin/bash Code:
1 Code:
sh avg |
Whoops, Andrew got his in a few minutes before mine, and I didn't see it. His is simpler, and takes input more in the way you were asking for them.
|
Yes, but it doesn't do decimals, I had to use bc for that
Code:
#!/bin/bash |
All times are GMT -5. The time now is 07:37 AM. |