Question: What Are Shell Variables in Linux?

Question: What Are Shell Variables in Linux?
Contents

A shell variable is a variable that is available only to the current shell. In contrast, an environment variable is available system wide and can be used by other applications on the system. A shell is the operating system’s command interpreter.

What are shell variables used for?

A shell script allows us to set and use our own variables within the script. Setting variables allows you to temporarily store data and use it throughout the script, making the shell script more like a real computer program. User variables can be any text string of up to 20 letters, digits, or an underscore character.

What are the two types of shell variables?

A shell can have two types of variables:

  • Environment variables – Variables that are exported to all processes spawned by the shell. Their settings can be seen with the env command. …
  • Shell (local) variables – Variables that affect only the current shell.
Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.