[Solved] [Bash] How bash treats variables
Posted: 2023-11-28 02:39
Code: Select all
$ foo=bar
$ echo $foo
bar
$ foo=baz echo $foo
bar
$ foo=baz sh -c 'echo $foo'
baz
Can anybody explain to me why foo=baz echo $foo results in bar, but then it works properly when I use sh -c?
Thanks!