HEALTH WARNING: Care should be taken when lifting this product, since its mass, and thus its weight, is dependent on its velocity relative to the user.
"Tittom" <tittom@free.fr> writes:
Bonjour
Plutot que des mots longs, voici ce que j'essaie de faire :
[debut de code]
animal="chien"
echo $animal
chien
read phrase
Mon animal est un $animal
echo $phrase
Mon animal est un $animal
[fin de code]
J'aimerai obtenir "Mon animal est un chien" lorsque je fais "echo
$phrase".
Je ne comprends pas pourquoi $animal n'est pas "évalué".
Parce que tu ne l'as pas évalué!
[pjb@thalassa tmp]$ animal=chien
[pjb@thalassa tmp]$ echo $animal
chien
[pjb@thalassa tmp]$ read phrase
Mon animal est un $animal
[pjb@thalassa tmp]$ echo $phrase
Mon animal est un $animal
[pjb@thalassa tmp]$ eval "echo $phrase"
Mon animal est un chien
[pjb@thalassa tmp]$
HEALTH WARNING: Care should be taken when lifting this product,
since its mass, and thus its weight, is dependent on its velocity
relative to the user.
HEALTH WARNING: Care should be taken when lifting this product, since its mass, and thus its weight, is dependent on its velocity relative to the user.
Tittom
On 16 fév, 15:33, Sébastien Monbrun aka TiChou wrote:
J'aimerai obtenir "Mon animal est un chien" lorsque je fais "echo $phrase". Je ne comprends pas pourquoi $animal n'est pas "évalué".
Parce que justement la variable phrase n'a pas été évalué.
Donc, évaluons là :
$ eval echo "$phrase"
Effectivement ça change tout ! Capito, merci.
On 16 fév, 15:33, Sébastien Monbrun aka TiChou <gro.uohcit@uohcit>
wrote:
J'aimerai obtenir "Mon animal est un chien" lorsque je fais "echo
$phrase".
Je ne comprends pas pourquoi $animal n'est pas "évalué".
Parce que justement la variable phrase n'a pas été évalué.