Liste des Groupes | Revenir à cu shell |
Hi there ! >uname -sr | { read var3 ; echo $var3 ; }
>
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? >
Les messages affichés proviennent d'usenet.