Script bash division

xunil2003 -  
zipe31 Messages postés 36402 Date d'inscription   Statut Contributeur Dernière intervention   -
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.

A voir également:

3 réponses

Utilisateur anonyme
 
salut,

declare -i division
division=2340/60
echo $division
39
1
dubcek Messages postés 18789 Date d'inscription   Statut Contributeur Dernière intervention   5 637
 
hello
$ DIVISION=$((2340/60))
$ echo "résultat $DIVISION"
résultat 39
$ 
1
xunil2003 Messages postés 765 Date d'inscription   Statut Membre Dernière intervention   14
 
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.
0
zipe31 Messages postés 36402 Date d'inscription   Statut Contributeur Dernière intervention   6 430
 
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
0