Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. Variables, Making Decisions, and Repe... > 6.1. Variables and Arithmetic

Variables and Arithmetic

Shell variables are like variables in any conventional programming language. They hold values until you need them. We described the basics of shell variable names and values in Section 2.5.2. In addition, shell scripts and functions have positional parameters, which is a fancy term for “command-line arguments.”

Simple arithmetic operations are common in shell scripts; e.g., adding one to a variable each time around a loop. The POSIX shell provides a notation for inline arithmetic called arithmetic expansion. The shell evaluates arithmetic expressions inside $((...)), and places the result back into the text of the command.

Variable Assignment and the Environment


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint