functionVariables

Local variables and environmental variables

To differentiate further:

  • Local Variables:

    • Are defined and accessed only within the shell they are created in.

    • Serve as temporary storage for data used in scripts or during interactive shell use.

    • Do not affect the system-wide state or other shell sessions.

    • Local is only available in the shell it is created in; it is user-specific.

  • Environment Variables:

    • Can be inherited by child processes; for instance, when a script runs a command, the environment variables from the script can be accessed by that command.

    • Are used to configure the environment in which applications or shell scripts run.

    • Common examples include PATH, HOME, USER, and LANG, each serving specific roles like specifying directories to search for executables or defining default user locales.

    • Environmental / Gloabel is available to the whole system. This is located in /etc

As you can see in the image above, the variable GEEKSFORGEEKS is being set for SITE; then, you are using grep to post the output of SITE. To see more documentation on variables and how they work in Linux, look at the GeekforGeeksarrow-up-right documentation they posted. It is beneficial and makes understanding variables easy.

Last updated