How can I do division with variables in a Linux shell?

前端 未结 6 1022
南旧
南旧 2020-12-22 20:38

When I run commands in my shell as below, it returns an expr: non-integer argument error. Can someone please explain this to me?

$ x=20
$ y=5
$          


        
6条回答
  •  囚心锁ツ
    2020-12-22 21:04

    let's suppose

    x=50
    y=5
    

    then

    z=$((x/y))
    

    this will work properly . But if you want to use / operator in case statements than it can't resolve it. In that case use simple strings like div or devide or something else. See the code

提交回复
热议问题