Universal Data Mover - fordata Statement

Universal Data Mover - fordata Statement

fordata Statement

The fordata statement iterates through a data element, once for each line. For each iteration, a variable provided by the user is set to hold the contents of the line in the data element corresponding to the current iteration.

Syntax

The syntax of the fordata statement is:

fordata variable-name=data-element ... end



Example

set i=1 loaddata mydata=mydata.txt fordata line=mydata echo "$(i): $(line)" compare "$(line)" "exit" case=yes if <"$(_lastrc.message)" EQ "MATCH"> echo echo "Data contains an 'exit' command" echo end set i=<$(i) + 1> end




If a data element called mydata.txt contained the following contents:

cd / ls -al exit




Running this script against the contents of mydata would produce the following results:

1: cd / 2: ls -al 3: exit Data contains an 'exit' command