Shell Variable

What Does Shell Variable Mean?

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. It processes the commands entered on the command line or read from a shell script file.

Techopedia Explains Shell Variable

A variable is a location in memory that is used to hold a value. This location is assigned a name to make it descriptive. The value could be any type of data such as a name, number, text or filename/directory. So, a variable is nothing more than a pointer to a particular data. A shell allows a user to create, assign or delete variables. However, these variables are only temporary and are automatically deleted when the shell session is closed. To make a shell variable persistent and available system wide, it must be exported, thus converting it into an environment variable. The command used for doing this depends on the specific shell being used. In the Bash shell used by Linux, the command is “export”.

A shell variable is created with the following syntax: “variable_name=variable_value”. For example, the command “set COMPUTER_NAME=mercury” creates the shell variable named “COMPUTER_NAME” with a value of “mercury”. For values with spaces, quotation marks must be used. Although not required, the convention in Unix is to use uppercase letters for the variable names. Also, in Unix, variable names, like filenames, are case sensitive.


Related Terms

Latest Privacy and Compliance Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…