I am building a movie database and I need to find a median for ratings. I'm really new to bash (it's my first assignment).
I wrote:
let evencheck=$"(($Amount_of_movies-$Amount_of_0_movies)%2)"
if [ $evencheck==0 ]
then
let median="(($Amount_of_movies-$Amount_of_0_movies)/2)"
else
let median="(($Amount_of_movies-$Amount_of_0_movies)/2)+1"
fi
When $amount_of_movies = 6
and $amount_of_0_movies = 1
. I would expect median to be 3. but it's 2. Why is that?