1

Can somebody tell me why my command language interpreter shell shows me an empty string as the result after the command

$ echo $VERSION

And only after executing this command

$ . /etc/os-release

it begins to show me the result of that command

$ echo $VERSION

18.04.3 LTS (Bionic Beaver)

can you, please, explain me what happens after that command? Why had not shell shown it before? Why does shell show it now?

1 Answers1

4

Running ". /etc/os-release" will run all lines in file "/etc/os-release" in your current shell; It seems that the file you are sourcing has a line like below that will set environment variable "VERSION" in your session:

VERSION="18.04.3 LTS (Bionic Beaver)"

If you are using bash then "source" will give you the same result: "source /etc/os-release"

You can check these in detail: https://ss64.com/bash/source.html or https://superuser.com/questions/46139/what-does-source-do

  • 1
    It's a shell variable that it sets; os-release is technically not a shell script (see man os-release); you have missed explaining the important point that there is no standard VERSION shell variable; and Unix and Linux has https://unix.stackexchange.com/q/58514/5132, and https://unix.stackexchange.com/q/17815/5132, and https://unix.stackexchange.com/q/43882/5132, and https://unix.stackexchange.com/q/312573/5132, and https://unix.stackexchange.com/q/459087/5132, and … – JdeBP Jan 10 '20 at 06:55
  • @JdeBP wow, thank you. all a matter of dot. – Yana Shetko Jan 10 '20 at 11:05