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

Chapter 11: Using Structured Commands > Advanced if-then Features

Advanced if-then Features

There are two relatively recent additions to the bash shell that provide advanced features that you can use in if-then statements:

  • Double parentheses for mathematical expressions
  • Double square brackets for advanced string handling functions

The following sections describe each of these features in more detail.

Using Double Parentheses

The double parentheses command allows you to incorporate advanced mathematical formulas in your comparisons. The test command only allows for simple arithmetic operations in the comparison. The double parentheses command provides more mathematical symbols, which programmers, who have used other programming languages, may be used to using. The format of the double parentheses command is:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


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