Deutsch   English   Français   Italiano  
<st6mb4$4pb$1@gioia.aioe.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!aioe.org!FdrTMw7+RJa5kGNwdwd/KQ.user.46.165.242.91.POSTED!not-for-mail
From: Dominique <zzz@aol.com.invalid>
Newsgroups: fr.comp.os.linux.configuration
Subject: =?UTF-8?Q?Re=3a_Script_Bash/Sh_split_chaine_de_caract=c3=a8re_et_va?=
 =?UTF-8?Q?riables?=
Date: Sun, 30 Jan 2022 19:44:51 +0100
Organization: Aioe.org NNTP Server
Message-ID: <st6mb4$4pb$1@gioia.aioe.org>
References: <3dCdnd3L8_XSGWj8nZ2dnUU7_83NnZ2d@giganews.com>
 <20220129155515.340f1f85@coffee.novazur.fr> <st576n$1bob$1@gioia.aioe.org>
 <61f69cce$0$29502$426a34cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="4907"; posting-host="FdrTMw7+RJa5kGNwdwd/KQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: fr
Bytes: 2059
Lines: 30

Le 30/01/2022 à 15:12, Nicolas George a écrit :
> Dominique , dans le message <st576n$1bob$1@gioia.aioe.org>, a écrit :
>>> $ FICHIER="ceci est une chaine avec des espaces"
>>> $ for MOT in $FICHIER ; do TABLEAU+=($MOT) ; done
>>> $ echo ${TABLEAU[0]}
>>> ceci
>>> $ echo ${TABLEAU[3]}
>>> chaine
> 
>> Mais dans l'exemple que tu donnes, je retrouve du Python. bash et Python
>> seraient proches ?
> 
> Que vois-tu dans cet exemple qui ressemble à du python ?

La boucle for in, mais qui est transverse à de nombreux langages. Par 
contre, c'est la liste TABLEAU qui m'interpelle avec les appels par 
index comme TABLEAU[2]

J'utilise en permanence cette indexation avec Python.

Exemple : TABLEAU=[[i**2] for i in range (10)]

ce à quoi TABLEAU = [[0], [1], [4], [9], [16], [25], [36], [49], [64], [81]]

Et j'appelle TABLEAU [2] qui me donne 4.

Là, je retrouve Python dans ton script :-)

Bonne soirée,

Dominique