Chapter 5. Exploring Expressions and Variables

In the last chapter, you learned about how shell interprets any command, which is entered in the terminal or the command line. We also studied command substitution and separators in detail.

In this chapter, we will cover following topics:

  • Working with environment variables
  • Exporting variables
  • Working with read-only variables
  • Working with command line arguments (special variables, set and shift, and getopt)
  • Working with arrays

Understanding variables

Let's learn about creating variables in shell.

Declaring variables in Linux is very easy. We just need to use the variable name and initialize it with the required content.

$ person="Ganesh Naik"

To get the content of the variable we need to prefix $ before the ...

Get Learning Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.