You are previewing The Linux Command Line.

The Linux Command Line

Cover of The Linux Command Line by William E. Shotts Jr. Published by No Starch Press
O'Reilly logo

Variables and Constants

There is an issue with our script, however. Notice how the string System Information Report is repeated? With our tiny script it’s not a problem, but let’s imagine that our script was really long and we had multiple instances of this string. If we wanted to change the title to something else, we would have to change it in multiple places, which could be a lot of work. What if we could arrange the script so that the string appeared only once and not multiple times? That would make future maintenance of the script much easier. Here’s how we could do that:


# Program to output a system information page

title="System Information Report"

echo "<HTML>
                <H1>$title</H1> </BODY> ...

The best content for your career. Discover unlimited learning on demand for around $1/day.