clavier

Choix aléatoire dans un tableau en bash

Plouf Plouf une allumette prend feu ...

linux tableau choix, coloriser grep, not provided

Voici un petit code qui permet de choisir de manière aléatoire un élément dans un tableau en [b]bash(/b].


#!/bin/bash
choices=("un" "deux" "trois")
choice=${choices[$RANDOM%${#choices[*]}]}
echo "$choice"

Image : bru76

 
 

b1n@sp1n