Sujet : Different variable assignments De : usenet (at) *nospam* f.winkler-ka.de (Frank Winkler) Groupes :comp.unix.shell Date : 11. Oct 2024, 19:11:57 Autres entêtes Message-ID :<lmt83dFsvbvU3@mid.individual.net> User-Agent : Mozilla Thunderbird Beta
Hi there ! Consider the following commands: $ var1=`uname -sr` $ echo $var1 Darwin 24.0.0 $ read var2 <<< `uname -sr` $ echo $var2 Darwin 24.0.0 $ uname -sr | read var3 $ echo $var3 $ uname -sr | read -p var3 $ echo $var3 $ While the first two ones behave like expected, I wonder why the latter ones fail. What's the difference behind the scenes? And even more confusing, why does this familiar one work anyway? $ sw_vers | while read line; do echo $line; done ProductName: macOS ProductVersion: 15.0.1 BuildVersion: 24A348 $ I've been using commands like that one for a very long time and that's why I tried the simple "read" above - with no success. How can I do such an assignment at the end of a command instead of the beginning? Any ideas? TIA fw