First page Back Continue Last page Graphics

I/O Redirection and Subshells for Loops (Pages 923 – 927)

The whole of a loop right down to the done statement can be treated as a unit for redirection and background processing, so that constructs like these are possible:

Pipe data into or out of a loop:

command | for do … done

while do … done | command

Redirect file output or input for a loop:

until do … done >> filename

while do … done < filename

Run a loop entirely in the background:

for do … done &