Using case for a range of numbers in Bash

前端 未结 5 757
忘掉有多难
忘掉有多难 2020-11-29 06:59

I am trying to do the following using case in Bash (in Linux).

If X is between 460 and 660, output X information.

If X is between 661 and 800, d

5条回答
  •  萌比男神i
    2020-11-29 07:19

    Just for the pleasure of subverting case to do as you want, you can use $((...))

    case 1 in
        $(($MovieRes<= 460)))echo "$MovieName,???";;
        $(($MovieRes<= 660)))echo "$MovieName,480p";;
        $(($MovieRes<= 890)))echo "$MovieName,720p";;
        $(($MovieRes<=1200)))echo "$MovieName,1080p";;
                           *)echo "$MovieName,DVD";;
    esac >> moviefinal
    

提交回复
热议问题