Explain the while construct, and demonstrate how it can be used.

What will be an ideal response?


The while construct is a common loop construct used within shell scripts. The while construct begins with a test statement. As long as (i.e. while) the test statement returns true, the commands within the loop construct are executed. When the test statement returns false, the commands within the while construct stop executing. A while construct typically contains a variable, called a counter variable, whose value changes each time through the loop. For the while construct to work properly, it must be set up so that, when the counter variable reaches a certain value, the test statement returns false. This prevents the loop from executing indefinitely.The syntax of the while construct is as follows:whilethis returns truedothese commandsdone

Computer Science & Information Technology

You might also like to view...

Given the following header for a function named computeValue, which of the following is a valid call to the function?

void computeValue(int value) a. computeValue(10) b. computeValue(10); c. void computeValue(10); d. void computeValue(int x);

Computer Science & Information Technology

When creating a new workbook, any templates that you create can be displayed by clicking Personal in the New panel

Indicate whether the statement is true or false

Computer Science & Information Technology

The feature that displays table column heads at the top of each page is

A. Page Header B. Repeat Header Rows C. Distribute Rows D. Distribute Columns

Computer Science & Information Technology

A client using a PPTP VPN to connect to a private LAN will have an IP address of that network, just as if it were directly connected to the LAN, right down to this IP configuration setting, which will control where that client's packets with destination addresses beyond the LAN will be sent.

A. DNS B. default gateway C. WINS D. PPP

Computer Science & Information Technology