Chapter 11. Advanced Shell Programming

Chapter Syllabus

  • 11.1 Arithmetic and Logic Operations

  • 11.2 The while-do-done Loop

  • 11.3 The until-do-done Loop

  • 11.4 The for-do-done Loop

  • 11.5 Breaking a Loop

  • 11.6 Text Processing

Loops are used to perform an operation repeatedly until a condition becomes true or false. The test or let command is used to check the condition every time a repetition is made. All loop structures used in shell programming start with a keyword. The block of commands that is executed repeatedly is enclosed by the do-done keywords.

There are three basic types of loops. The first one is the for-do-done loop, which is used to execute a block of commands for a fixed number of times. The while-do-done loop checks for a condition and goes on executing ...

Get HP-Certified HP-UX System Administration 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.