Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ foreach(1) — SunOS 5.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

break(1)

csh(1)

ksh(1)

sh(1)

for(1)

NAME

for, foreach − shell built-in functions to repeatedly execute action(s) for a selected number of times

SYNOPSIS

sh

for name [ in word... ] ; do actions ; done

csh

foreach var (wordlist)
   ...
end

ksh

for identifier [ in word ... ] ; do actions ; done

DESCRIPTION

sh

Each time a for command is executed, name is set to the next word taken from the in word list.  If in word ... is omitted, then the for command executes the do actions once for each positional parameter that is set. Execution ends when there are no more words in the list.

csh

The variable var is successively set to each member of wordlist. The sequence of commands between this command and the matching end is executed for each new value of var. Both foreach and end must appear alone on separate lines. 

The built-in command continue may be used to terminate the execution of the current iteration of the loop and the built-in command break may be used to terminate execution of the foreach command.  When this command is read from the terminal, the loop is read once prompting with ?  before any statements in the loop are executed. 

ksh

Each time a for command is executed, identifier is set to the next word taken from the in word list.  If in word ... is omitted, then the for command executes the do actions once for each positional parameter that is set Execution ends when there are no more words in the list. 

SEE ALSO

break(1), csh(1), ksh(1), sh(1)

NOTES

Both the Bourne shell, sh, and the Korn shell, ksh, can use the semicolon and the carriage return interchangeably in their syntax of the if, for, and while built-in commands. 

SunOS 5.4  —  Last change: 15 Apr 1994

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026