#!/bin/bash # méthodes 1 : tab=(salade_verte, savoyarde, niçoise,) echo ${tab[0]} echo ${tab[1]} echo ${tab[2]} echo "Nous avons dit : ${tab[*]} c-à-d ${#tab[@]} choix." echo " " #méthode 2: declare -a tableau=(entrecôte, cabillaud, fruits_de_mer, frites, gratin_dauphinois) echo ${tableau[0]} echo ${tableau[1]} echo ${tableau[2]} echo "Nous avons dit : ${tableau[*]} c-à-d ${#tableau[@]} choix de plus." echo " " #méthode 3 : t=( [0]=glace, [1]=tarte-maison, [2]=yahourt, [3]=pudding, [4]=fruits,) echo ${t[0]} echo ${t[1]} echo ${t[2]} echo ${t[3]} echo ${t[4]} echo "Nous avons dit : ${t[*]} c-à-d ${#t[@]} choix de plus." #méthode 4 par la lecture : echo "Écrivez ce qu'il manque à cette liste, svp ? : " read -a tb echo "vous auriez souhaité : ${tb[*]} " echo "la liste est maintenant : ${tab[*]} ${tableau[*]} ${t[*]} ${tb[*]}" declare -a arrayconcat=("${tab[@]}" "${tableau[@]}" "${t[@]}" "${tb[@]}") echo "Cela nous fait une liste de ${#arrayconcat[@]} choix !"