Using Variables in Shell Scripts

When writing shell scripts for Linux, you work with three types of variables:

• Environment variables Part of the system environment, you can use them in your shell program. New variables can be defined, and some of them, such as path, can also be modified within a shell program.

• Built-in variables These are variables such as options used on the command (interpreted by the shell as a positional argument) are provided by Linux. Unlike environment variables, you cannot modify them.

• User variables Defined by you when you write a shell script. You can use and modify them at will within the shell program.

A major difference between shell programming and other programming languages is that in shell programming, variables are not typedthat is, you do not have to specify whether a variable is a number or a string, and so on.

Was this article helpful?

0 0

Post a comment