O'Reilly logo

Linux Shell Scripting with Bash by Ken O. Burtch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Variables

The results of commands can be written to a file or saved in variables. Because variables are saved in memory, they tend to be faster to examine than files. Bash doesn't put an upper limit on the size of a variable: They are large enough to contain anything you will ever need to hold.

Using variables is essential to shell script programming. This chapter is an in-depth look at variables and how they are used in the shell, from basic variables to expanding variables with the eval command.

Variable Basics

Variables are declared using the Bash declare command. To declare a variable named COST, use this:

$ declare COST

Use the built-in typeset statement for compatibility with the Korn shell. If you are using Bash, use declare instead. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required