Path: ...!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!news.mixmin.net!aioe.org!Faqf6A55NG1s8DSVkh3L9A.user.46.165.242.75.POSTED!not-for-mail From: Alain Ketterlin Newsgroups: fr.comp.os.unix Subject: Re: bash : fonction min Date: Mon, 18 Oct 2021 20:52:59 +0200 Organization: =?utf-8?Q?Universit=C3=A9?= de Strasbourg Message-ID: <87k0ia5fn8.fsf@universite-de-strasbourg.fr.invalid> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: gioia.aioe.org; logging-data="6456"; posting-host="Faqf6A55NG1s8DSVkh3L9A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) X-Notice: Filtered by postfilter v. 0.9.2 Cancel-Lock: sha1:WcPsRLUPqHnbCYixYayKP3vWsPw= Bytes: 1775 Lines: 23 Thomas writes: > existe-t-il une fonction min dans bash ? > j'imagine =C3=A7a disponible parmi les op=C3=A9rations math=C3=A9matiques= auxquelles on=20 > acc=C3=A8de via $(( )) $(( X < Y ? X : Y )) > =C3=A0 d=C3=A9faut, pouvez vous me faire un if avec une condition d'in=C3= =A9galit=C3=A9 svp ? Deux solutions : 1) if test $X -lt $Y; then ...; else ...; fi 2) if [[ $X < $Y ]]; then ...; else ...; fi La seconde est sp=C3=A9cifique =C3=A0 bash. Toute cela suppose que X et Y contiennent effectivement des nombres. Et =C3=A7a ne fait que du calcul entier. Si tu as besoin de plus compliqu=C3=A9, cf bc/awk/... ou ton langage de script pr=C3=A9f=C3=A9r=C3=A9. -- Alain.