O'Reilly logo

Expert Shell Scripting by Ron Peters

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 4Comparisons and Tests

Two of the fundamental types of operations in any programming language are the comparison and the test. They are the building blocks of conditional statements (if/then and case) and iteration statements (while). They give you the ability to examine relationships between data items, such as files, variables, strings, and numeric values, and to take action based on the result. You can also carry out actions based on the attributes of a particular item, such as a file's type, whether a variable has been assigned a value, and the return code of a command.

The examples in this chapter illustrate various ways to compare items or to check their properties, and use the results. I have used all of these techniques throughout ...

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