Script bash division

Bonjour,

Dans un script bash je n'arrive pas a faire une division.
#---------------  (DIVISION) ---------------
DIVISION=2340/60
echo "résultat $DIVISION"


Mais le résultat ne s'affiche pas ?
Ou ai je fait l'erreur ?

Merci.

3 réponses

  • Votes
  • Date
  • Date décroissante
  1. salut,

    declare -i division
    division=2340/60
    echo $division
    39
    1. Contributeur
      hello
      $ DIVISION=$((2340/60))
      $ echo "résultat $DIVISION"
      résultat 39
      $ 
      1. Bonjour

        Comment diviser un nombre avec une point.

        laurent@PC-ubuntu:~$ DIVISION=$((300.6/8)) $DIVISION
        bash: 300.6/8 : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est ".6/8")
        laurent@PC-ubuntu:~$ 


        Autre essai
        laurent@PC-ubuntu:~$ echo "scale=1;(300.6/8))" | bc
        (standard_in) 1: syntax error
        laurent@PC-ubuntu:~$


        Merci.
        1. Contributeur
          Salut,

          echo "scale=1;(300.6/8))" | bc
          T'as fait une erreur en recopiant ton opération, il y a une parenthèse en trop ;-\

          $ echo "scale=1;(300.6/8)"| bc
          37.5